Can't figure out why getting "query was empty" error

From: Date: Sun, 24 Dec 2006 04:49:36 +0000
Subject: Can't figure out why getting "query was empty" error
Groups: php.db 
Request: Send a blank email to php-db+get-42856@lists.php.net to get a copy of this message
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.

« previous php.db (#42856) next »