|
Posted by Tom on 12/28/07 07:24
On Thu, 27 Dec 2007 22:53:57 -0500, Jerry Stuckle wrote...
>
>jcage@lycos.com wrote:
>> Can someone help me with an issue I'm having with a bit of PHP code as
>> it connects to a database? I'm trying to use the code below to let a
>> user know that there is a problem connecting to the database and for
>> whatever reason, cannot get the portion within the double quotes below
>> to function properly (double quotes around the code is normally not
>> there). PHP version is 4.1.1 so I'm wondering if perhaps the
>> mysql_connect_errno (have tried 'error' in place of errno) is too
>> advanced possibly for this php version because I can't get the code
>> working.
>>
>> Code works fine without the error trapping portion below assuming a
>> connection took place but otherwise, has created an issue on one
>> occasion that I know of so I'd like to get the error trap in place.
>> thanks for any pointers.
>>
>> John
>>
>> "if (mysql_connect_errno())
>> {
>> echo 'Error: Could not connect to database. Please try again
>> later.';
>> exit;
>> }"
>>
>> mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to
>> database"); // make connection to database
>> mysql_select_db($DBName) or die("Unable to select database
>> $DBName"); // select database
>> if (mysql_connect_errno())
>> {
>> echo 'Error: Could not connect to database. Please try again
>> later.';
>> exit;
>> }
>> $sqlquery = "INSERT INTO $table VALUES('$id', '$time', '$month',
>> '$year')";
>> if ($results = mysql_query($sqlquery)) {
>>
>
>There is no function mysql_connect_errno() (or mysql_connect_error()).
>
At the PHP site link, I think there's a few functions like mysql_errno() and
mysql_error(), that can be used to get error information...
http://us.php.net/manual/en/ref.mysql.php
Tom
--
NewsGuy Accounts Go Jumbo!
NewsGuy Express increased from 30 to 50 GB of download capacity
http://newsguy.com/overview.htm
Navigation:
[Reply to this message]
|