I've got a block of code that's similar to the following:
$query = "SELECT badfield FROM tablename";
$getdata = mysql_query($query,$connection);
if ($err = mysql_error()) die("Query failed. Server said: $err");
This code should hit the die() clause. However, it's not. If I try to loop through the query results it will throw an error there, but the trap will not catch it. The only thing I can think of is I have 2 connection strings in my config file that look like this:
/* Open Connection */
$connection = mysql_connect($database,$dbuser,$dbpass) or die ("System Connection Failed!<br>");
$db = mysql_select_db($dbname,$connection) or die ("Database Connection Failed!<br>");
/* Open Secure Connection */
$secure_connection = mysql_connect($secure_database,$secure_dbuser,$secure_dbpass) or die ("Secure System Connection Failed!<br>");
$secure_db = mysql_select_db($secure_dbname,$secure_connection) or die ("Secure Database Connection Failed!<br>");
I've read about the mysql_connect not working properly if you pass it duplicate information. However, as you can see, that's not the case. I also know the separate connect strings are working because the queries that do not return errors are returning proper results. I'm at my wits end on this one so any help would be greatly appreciated!