Re: What is wrong with this INSERT?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux