
December 7th, 2012, 05:18 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Location: Maine
Posts: 18
Time spent in forums: 5 h 36 m 24 sec
Reputation Power: 0
|
|
|
Failing to pull the mysql_error() value using a variable
Hello All,
I'm creating a small error logger in my php code but I'm having issues getting the 1 variable to work with mysql_error().
Can anyone see what I'm doing wrong? The only issue I have for submitting to my 'logs' table is that 1 variable ($error) with the $sql2 variable. If I place 'text' there, it works fine.
Code:
if (!$con) {
$error = mysql_error();
$con2 = mysql_connect($dbhost,$dbun,$dbpw2);
mysql_select_db($db1,$con2);
$sql2 = "INSERT INTO logs (error,cause) VALUES ($error,'Database Connection Failure')"; // all other $error variables work as intended, just not this one
mysql_query($sql2,$con2);
die('Could not connect: ' . $error);
}

|