On Tue, 19 Jun 2001 08:41, Todd A. Jacobs wrote:
> PHP: 4.0.4pl1
> MySQL: 3.23.36-1
>
> I have the following code fragment, which uses the same connection
> parameters elsewhere to *successfully* to retrieve data from a
> database, so this doesn't appear to be a permissions problem with
> MySQL.
>
> However, nothing happens with inserts; no rows are added at all. All I
> get is a message form mysql_error() saying "Query was empty."
>
> Can anyone tell me what might be wrong?
>
>     $user_idx  = 1;
>     $objective = 1;
>     $question  = 'Foo';
>     $question_type = 'singular';
>
>     $connection_id = mysql_connect ('192.168.1.1', 'php', 'password')
>       or die ("No connection.\n");
>
>     $sql = "INSERT INTO question VALUES (NULL, $user_idx, $objective,
>       '$question', '$question_type', NULL, NULL)";
>
>     $result = mysql_db_query('item_db', $sql_query, $connection_id);
>
>     echo "<pre>";
>     echo "\nDebugging output:\n";
>     echo "\tSQL: $sql\n";
>     echo "\tError: ", mysql_error(), "\n";
>     echo "\tLast insert ID: ", mysql_insert_id(), "\n";
>     echo "\tResult: $result\n";
>     echo "</pre>\n";

Your INSERT statement is contained in the variable $sql but you are using 
$sql_query in the mysl_db_query function?

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   URA Redneck if your funeral has more pickup trucks than cars.

Reply via email to