php-windows Digest 16 Sep 2005 04:40:14 -0000 Issue 2774
Topics (messages 26328 through 26332):
Re: I Can't connect to MySql using ADODB
26328 by: Mark Rees
Calling MSSQL Stored Procedure
26329 by: Alf Stockton
26330 by: Robert Twitty
26331 by: Alf Stockton
MSIE problems
26332 by: Bob Stout
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
> Tony Aldemir wrote:
>
> >Hi There,
> >
> >I am trying to connect to MySQL using ADODB library for PHP using the
> >following code with no success. What am I doing wrong?
> >
> ><?php
> >include('/php/adodb.inc.php');
> >
> >$db = &ADONewConnection('mysql'); # eg. 'mysql' or 'oci8'
> >$db->debug = true;
> >$db->Connect('localhost', 'tony', 'mypassword', 'test');
> >$rs = $db->Execute('select * from users');
> >print "<pre>";
> >print_r($rs->GetRows());
> >print "</pre>";
> >?>
> >
> >Notes:
> >1) After unzipping the downloaded ADODB file into a directory, I copied
the
> >adodb.inc.php file by itself into my c:\PHP directory. The ADODB
> >documentation says "Unpack all the files into a directory accessible by
your
> >webserver". What does this mean? Is there a setting somewhere in the
> >Apache Server that I need to tweak (e.g. some sort of setting in the
> >httpd.conf)?
> >
> >2) By the way, I CAN connect to MySQL using PHP directly (i.e. without
the
> >use of ADODB) just fine and work with the 'test' database's 'users'
table.
> >
> >
> >
> "Unpack all the files into a directory accessible by your webserver" means
placing those files either in the htdocs folder or a folder below that one.
ie Unless you have fiddled with Apache settings in httpd.conf Apache
controls what folders browsers can see on your server and the default is as
I have stated above.
> An example would be my setup which is http://localhost/Kiosk/debug.html
and it finds my adodb files in c:\Pogram Files\Apache
Group\Apache2\htdocs\Kiosk\adodb. From that you can see, if I have explained
clearly enough, that a browser looking at http://localhost/Kiosk/debug.html
cannot "see" anything below c:\Program Files\Apache
Group\Apache2\htdocs\Kiosk and for that matter I could place the debug.html
in htdocs rather than Kiosk and the browser command would be
http://localhost/debug.html in other words Apache defaults to htdocs as the
root.
>
Further to this, you can set the include_path in php.ini. It is generally
recommended to put these files outside the webroot (htdocs as described
above).
More information
http://uk2.php.net/manual/en/ini.core.php#ini.include-path
--- End Message ---
--- Begin Message ---
Thanks for the suggestions on ADODB which, thanks to you, I have
implemented.
I like the simularity between databases as my applications are going to
be accessing both MSSQL & Oracle.
The next step is for me to use ADODB & PHP to call various MSSQL and
Oracle Stored Procedurers so I am currently working my way throught the
ADODB documentation.
However, if one of you can come up with quick examples it would make my
task a little quicker and, of course, simplier
--
Regards,
Alf Stockton www.stockton.co.za
Nothing so needs reforming as other people's habits.
-- Mark Twain
My email disclaimer is available at www.stockton.co.za/disclaimer.html
--- End Message ---
--- Begin Message ---
On Thu, 15 Sep 2005, Alf Stockton wrote:
> Thanks for the suggestions on ADODB which, thanks to you, I have
> implemented.
>
> I like the simularity between databases as my applications are going to
> be accessing both MSSQL & Oracle.
>
> The next step is for me to use ADODB & PHP to call various MSSQL and
> Oracle Stored Procedurers so I am currently working my way throught the
> ADODB documentation.
>
> However, if one of you can come up with quick examples it would make my
> task a little quicker and, of course, simplier
>
Below is an example using the ADODB odbtp driver:
<?php
include('adodb/adodb.inc.php');
$DB = NewADOConnection('odbtp');
// Database connection
$constr = 'DRIVER={SQL
Server};SERVER=(local);UID=myuid;PWD=mypwd;DATABASE=OdbtpTest; ';
if( !$DB->PConnect( '127.0.0.1', $constr ) ) {
print $DB->ErrorMsg();
die;
}
// SQL Query Execution
$rs = $DB->Execute( "SELECT * FROM Employees" );
if( !$rs ) {
print $DB->ErrorMsg();
die;
}
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}
// Stored Procedure Execution
$stmt = $DB->PrepareSP( "GetTheIntsString" );
if( !$stmt ) {
print $DB->ErrorMsg();
die;
}
if( !$DB->Parameter( $stmt, $Id, "Id" ) ) {
print $DB->ErrorMsg();
die;
}
if( !$DB->Parameter( $stmt, $TheIntsString, "TheIntsString" ) ) {
print $DB->ErrorMsg();
die;
}
$Id = 123;
$rs = $DB->Execute( $stmt );
if( !$rs ) {
print $DB->ErrorMsg();
die;
}
echo "String = $TheIntsString\n";
$Id = 12;
$rs = $DB->Execute( $stmt );
if( !$rs ) {
print $DB->ErrorMsg();
die;
}
echo "String = $TheIntsString\n";
$Id = 72;
$rs = $DB->Execute( $stmt );
if( !$rs ) {
print $DB->ErrorMsg();
die;
}
echo "String = $TheIntsString\n";
?>
Code for GetTheIntsString stored procedure:
CREATE PROCEDURE GetTheIntsString
@Id int,
@TheIntsString varchar(256) = NULL OUTPUT
AS
SET NOCOUNT ON
SET @TheIntsString =
(SELECT 'Tiny Int = ' + CONVERT(varchar(32),TheTinyInt) + ' ' +
'Small Int = ' + CONVERT(varchar(32),TheSmallInt) + ' ' +
'Int = ' + CONVERT(varchar(32),TheInt) + ' ' +
'Big Int = ' + CONVERT(varchar(32),TheBigInt)
FROM TheInts WHERE Id = @Id)
GO
-- bob
--- End Message ---
--- Begin Message ---
I have to access a MsSQL stored procedure coded as follows :-
CREATE PROCEDURE spGetActivePromotions
@Today datetime
AS
SELECT PromotionID, PromotionName, StartDate, EndDate, LastDrawDate,
MaxDraws, NumRegTickets, VouchersPermitted, NumTicketsPerVoucher,
ManualTicketIssue
FROM Promotion
WHERE @Today>=StartDate AND @Today<=EndDate
GO
and therefore have coded my php as follows :-
$PMdriver = "mssql";
$PMdb = ADONewConnection($PMdriver);
$PMdb->Connect($PMserver, $PMuser, $PMpassword, $PMdatabase);
$SQL = $PMdb->Prepare("spGetActivePromotions");
$ActualDate = strftime("%Y/%m/%d %I:%m:%S %p");
$PMdb->InParameter($SQL, $ActualDate, "Today");
$PMdb->OutParameter($SQL, $ret, 'RETVAL');
but I keep getting the error message
201: Procedure 'spGetActivePromotions' expects parameter '@Today', which
was not supplied.
Please tell me how I got this wrong.
--- End Message ---
--- Begin Message ---
Although it works fine with Firefox, whenever I use a <select> object to
open a PHP file in a frame, with an internal reference, it ignores the
reference. IOW, if the link I want in the frame is "somefile.php",
everything works OK. If, instead, the link I want in the frame is
"somefile.php#here", it displays the file from the beginning, ignoring
the reference to the <name'"here"> tag.
Has anyone experienced this before and, if so, is there a work-around
for it?
--
Bob Stout <[EMAIL PROTECTED]> - The rules of life:
"Either lead, follow, or get out of the way."
"It's easier to get forgiveness than permission."
"90% of everything is garbage."
"Never attribute to malice what can be adequately explained by
stupidity."
--- End Message ---