Re: What is wrong with this INSERT?
| From: | Dave Goodchild | Date: | Thu, 29 Mar 2007 14:23:44 +0000 |
| Subject: | Re: What is wrong with this INSERT? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251616@lists.php.net to get a copy of this message | ||
Because of this:
$sql = mysql_query("INSERT INTO tbl (WHEN, WHAT, WHO) VALUES
('$WHEN','$WHAT','$WHO')");
$result = mysql_query($sql) or die("Fatal Error :".mysql_error());
...you are running the query and assigning the results into $sql and then
running mysql_query again in the line below. So the second query runs on a
result set rather than a query statement and fails. Better to do this, at
this rudimentary level:
$result = mysql_query("INSERT INTO tbl (WHEN, WHAT, WHO) VALUES
('$WHEN','$WHAT','$WHO')") or die(mysql_error());
-- http://www.web-buddha.co.uk