|
Posted by Jerry Stuckle on 12/28/07 03:53
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()).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|