Hello,

I am new to php so bear with me. I have a simple php file that tries to
insert data into a mySQL database table.

When I try to run it I get a "query was empty". I've googled this error
message and found many, many hits but I still can't figure out what's wrong
with my script.

Here's a snippet:
<?php
// Connect to db
$con=mysql_connect ("localhost", "<dbname>", "<password>") or die ('I cannot
connect to the database because: ' . mysql_error());
// Select db
mysql_select_db ("<table>");
echo(date("l dS \of F Y h:i:s A") . "<br />");

mysql_query("INSERT INTO person (FirstName, LastName, Age) VALUES('Jack',
'Bauer', '67')");
//Try to insert the record
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
// Close the connection
mysql_query($sql,$con);mysql_close($con);
?>


This seems like it should be a simple thing to do but I can NOT figure it
out.

Any help would be greatly appreciatetd.
-- 
View this message in context: 
http://www.nabble.com/Can%27t-figure-out-why-getting-%22query-was-empty%22-error-tf2876259.html#a8039188
Sent from the Php - Database mailing list archive at Nabble.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to