I'm using an HTML form to POST strings to this page:
<html>
<head>
<title>Update Db</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
/ INIT TABLES /
$link = mysql_connect("localhost","root","")
or die("Could not Connect");
// Select the dbQ database
if (! @mysql_select_db("db", $link) ) {
echo( "<P>Unable to locate the " .
"database at this time.</P>" );
exit();
}
/ GET TODAYS DATE /
$dstring = date("d/m/Y");
/ BUILD SQL STRING /
$sql = "INSERT INTO db.dbquestion (QRef,QTitle,Date,QCategory,Question,QTip,ClientName,ClientEmail)";
$sql .= " VALUES (NULL,";
$sql .= $QTitle;
$sql .= ",";
$sql .= $dstring;
$sql .= ",";
$sql .= $QCategory;
$sql .= ",";
$sql .= $Question;
$sql .= ",";
$sql .= $QTip;
$sql .= ",";
$sql .= $ClientName;
$sql .= ",";
$sql .= $ClientEmail;
$sql .= ")";
/ TEMP BUG CHECK, ECHO SQL STRING /
echo $sql;
/ INSERT DATA TO TABLE /
$junk = mysql_query($sql);
/ TEMP ECHO ERROR MESSAGE /
echo mysql_error($link);
/ CLOSE THE DATABASE /
mysql_close($link);
/ USER FEEDBACK /
?>
<p>Thank you for your question.</p>
<p> Please refer back tomorrow for your reply.</p>
<p> On <?echo $dstring; ?>, You said:</p>
<p> Title:
<? echo $QTitle; ?>
</p>
<p> Category:
<? echo $QCategory; ?>
</p>
<p> Question:
<? echo $Question; ?>
</p>
<p>Quick Tip:
<? echo $QTip; ?>
</p>
<p> Your Name:
<? echo $ClientName; ?>
</p>
<p> Your Email:
<?echo $ClientEmail; ?>
</p>
</body>
</html>
NOTES:
I've split the $sql string up for ease of reading.
The 'echo $sql' line works perfectly.
Fieldnames in HTML forms are the same as the fieldnames in the MySQL table.
The NULL is to update an autonumber field.
All the fields are text fields except QRef (autonumber) and Question (bigtext).
THE PROBLEM:
mysql_error returns "Unknown column <text of $QTitle > in 'field list' "
For <text of $QTitle > read "whatever is typed into the QTitle field".
Now I KNOW this has to be a simple error - but what? It's driving me nuts.
MORE INFO:
If I type a proper style email address into the ClientEmail, the error changes to "There is an error in your code near '@.com' ", if there is a space in anyof the fields I get the same message, pointing at the space.
Can anyone save my sanity?