can't connect to database error
Posted: Tue Jul 14, 2015 7:33 am
This is strange I return the first name and surname from a table. If I echo the 2 fields out I get the correct result. If however I try to use it in a html line I get an error Can't connect to database even though I have already done it and got the result set back.
I use a trigger error that sends me to an error page with this error, but it works fine if I don't try to use the result set in my page.
If I comment out the trigger error and use a standard connection it ALL works FINE.
I use a trigger error that sends me to an error page with this error, but it works fine if I don't try to use the result set in my page.
If I comment out the trigger error and use a standard connection it ALL works FINE.
Code: Select all
?
$qUserData = GetUser($ID);
$rs = mysql_fetch_array($qUserData);
//echo $rs['UserF'] . " " . $rs['UserS'];
//exit;
?>
<h2>Edit User Shelves for: <?=$rs['UserF']?></h2><br>
This works if I remove the commented out echo and exit.
=============
if(!$link = @mysql_connect($host, $user, $pass))
trigger_error('Can\'t connect to server: ('. $db . ')', E_USER_ERROR);
if(!$database = @mysql_select_db($data, $link))
trigger_error('Can\'t select database on: (' . $db . ')', E_USER_ERROR);
//$link = @mysql_connect($host, $user, $pass);
//$database = @mysql_select_db($data, $link);
If I remove the trigger errors and replace it with the normal connection it all works perfectly. The trigger error should be happening when I connect to the database not when I try to use
<h2>Edit User Shelves for: <?=$rs['UserF']?></h2><br>
This is strange...