Skip navigation links

MySQL Forums :: PHP :: MySQL Insert not working in PHP - "Query was Empty"


Advanced Search

MySQL Insert not working in PHP - "Query was Empty"
Posted by: Steve Allwine ()
Date: May 23, 2008 10:15AM

I have the following code. And the SQL Error that I get is "Query Failed:Query was Empty". Yet, I print the SQL to the screen and it looks OK. The SQL should be fine, because I can run it from server tools, and the record adds OK.
______________________________CODE_____________________________________
<?php session_start();?>
<HTML>
<HEAD>
<TITLE>Add Message - Add Record</TITLE>
</HEAD>
<BODY>
<?
//Write the Entry to the database
//Create a connection object.
$usr = "dbwriter";
$pwd = "password";
$db = "archivedb";
$host = "localhost";
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
//Insert Record
$sql = "INSERT INTO archive ( Type, Length, Speaker, Video, Audio, MP3, M4P, Realaudio , Filename, Dategiven, Title)";
$sql=$sql . "VALUES ('" . $_SESSION['type'] . "', '" . $_SESSION['length'] . "', '" . $_SESSION['speaker'] . "', '" . $_SESSION['video'] . "' , '" . $_SESSION['audio'] . "' , '" . $_SESSION['mp3'] . "' , '";
$sql=$sql . $_SESSION['m4p'] . "' , '" . $_SESSION['real'] . "' , '" .$_SESSION['filename'] . "', '" . $_SESSION['dategiven'] . "', '" . $_SESSION['title'] . "')";
echo $sql;
mysql_db_query($db,$SQL,$cid) or die("Query failed: " . mysql_error());
echo ("The Message has been added to our Archive database.");
echo ("<BR>".$result."<BR>");
mysql_close($cid);
?>
<FORM METHOD="post" ACTION="addmessage.php">
<INPUT TYPE="submit" VALUE="Add a New Message">
</FORM>

</BODY>
</HTML>

______________________________SCREEN OUTPUT________________________________


INSERT INTO archive ( Type, Length, Speaker, Video, Audio, MP3, M4P, Realaudio , Filename, Dategiven, Title)VALUES ('Sermon', '12', 'Gary Black', 'T' , 'T' , 'T' , 'T' , 'T' , 'test', '2008-05-23', 'test')

Query failed: Query was empty

Options: ReplyQuote


Subject Written By Posted
MySQL Insert not working in PHP - "Query was Empty" Steve Allwine 05/23/2008 10:15AM
Solved Steve Allwine 05/23/2008 10:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.