I'm rather new to PHP and to mysql. I have developed a number of simple things until I tried persuading a table to the an update.
Here is the code I generated:
//Make a persistent connection to the server passing the user name to the mysql db
//if there is an error, notify the user - if not notify the user
$conn = mysql_pconnect("ca.XXX.com", "webuser", "");
if (!$conn) {
echo "An error occured.\n";
exit;
}
if ($conn) {
echo "Connection to the server is successful.\n<br>";
}
$query = "Update test SET symptom = '$symptom', name = '$name', vm = '$vm', cust = '$cust', site_id = '$site_id', location = '$location', serial_no = '$serial_no', sw_vers = '$sw_vers', can_no = '$can_no', category = '$category', diag = '$diag', solution = '$solution', date = '$date' Where no = '$no'";
echo "'$query'<br>";
$result = mysql_db_query("mx8k", $query);
if (!$result) {
echo "you've got an error between line 35 and 38. \n"; //declare an error if there is something wrong in the structure of this script
}
//if the insertion is successful, thank the user (variable) and the reason (variable)
if ($result) {
echo "<p><h3>Thank you $name. <br>Your entry regarding ' $symptom ' was added to the Mx8000 Problems/Solutions Database,
<br>Thank You.</h3>";
}
//close the mysql connection
mysql_close($conn);
?>
The connection to the server and dB are fine. I can get the 'update' and enter it manually with success. But going through PHP is getting real frustrating. The hook I put in says that my error is between the $query and the $result. Since I can enter the data manually using just about the same as above without problems, I suspect that the issue is in the $result line. This is way to simple to be this difficult. Can somebody point me in the right direction and tell me what is wron in that line?
Tx, I really can't afford to lose anymore hair.
Here is the code I generated:
//Make a persistent connection to the server passing the user name to the mysql db
//if there is an error, notify the user - if not notify the user
$conn = mysql_pconnect("ca.XXX.com", "webuser", "");
if (!$conn) {
echo "An error occured.\n";
exit;
}
if ($conn) {
echo "Connection to the server is successful.\n<br>";
}
$query = "Update test SET symptom = '$symptom', name = '$name', vm = '$vm', cust = '$cust', site_id = '$site_id', location = '$location', serial_no = '$serial_no', sw_vers = '$sw_vers', can_no = '$can_no', category = '$category', diag = '$diag', solution = '$solution', date = '$date' Where no = '$no'";
echo "'$query'<br>";
$result = mysql_db_query("mx8k", $query);
if (!$result) {
echo "you've got an error between line 35 and 38. \n"; //declare an error if there is something wrong in the structure of this script
}
//if the insertion is successful, thank the user (variable) and the reason (variable)
if ($result) {
echo "<p><h3>Thank you $name. <br>Your entry regarding ' $symptom ' was added to the Mx8000 Problems/Solutions Database,
<br>Thank You.</h3>";
}
//close the mysql connection
mysql_close($conn);
?>
The connection to the server and dB are fine. I can get the 'update' and enter it manually with success. But going through PHP is getting real frustrating. The hook I put in says that my error is between the $query and the $result. Since I can enter the data manually using just about the same as above without problems, I suspect that the issue is in the $result line. This is way to simple to be this difficult. Can somebody point me in the right direction and tell me what is wron in that line?
Tx, I really can't afford to lose anymore hair.