Problem with insert

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a problem with an insert. The connection to DB works fine and I
receive an OK when the PHP process but nothing is inserted in the DB.
I added an echo of mysql_affected_rows and the result is -1. That's
why I get an OK?

$query="INSERT INTO preguntas (pregunta, id_usuario, fecha) VALUES
echo "OK";
echo "Nothing inserted";

Thanks for your help


Re: Problem with insert

zek2005 wrote:
Quoted text here. Click to load it

First of all, mysql_db_query was deprecated in PHP Version 4.0.5 and  
should not be used.  See the doc for more info.

And, just like in your previous question, you aren't checking the result  
of the query.  Did it work or not?  You'll either get a resource back or  
FALSE.  In the former case it worked.  In the latter case it didn't.

ALWAYS check the result of a MySQL call.  If it fails, use mysql_error()  
to display the error message.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Problem with insert

On Sun, 11 Feb 2007 05:53:51 -0800, zek2005 wrote:

Quoted text here. Click to load it

From the manual:
This function is deprecated, do not use this function. Use
mysql_select_db() and mysql_query() instead.

Or, if you insist on using a deprecated function, please check for
warnings: "If by chance no connection is found or established, an
E_WARNING level warning is generated." My guess is a username/password

Regards/mvh    Joachim Mæland

If everything seems under control, you're just not going fast enough.
-Mario Andretti.

Site Timeline