Page 1 of 1
How to check errors of a mysql_query?
Posted: Wed Sep 16, 2009 1:33 pm
by mischievous
I need to be able to check if the mysql_query($query) has any errors in it?
How do i display this?
Im trying to do an insert and its not inserting into mysql for some reason? was just working fine a couple minutes ago, now its not working at all?
Re: How to check errors of a mysql_query?
Posted: Wed Sep 16, 2009 2:07 pm
by jackpf
put "or die(mysql_error());" after the query...
Re: How to check errors of a mysql_query?
Posted: Wed Sep 16, 2009 3:33 pm
by superdezign
Yes,
mysql_error() is the function you are interested in.
Re: How to check errors of a mysql_query?
Posted: Wed Sep 16, 2009 4:04 pm
by Darhazer
jackpf wrote:put "or die(mysql_error());" after the query...
Not always failed query means end of script execution, maybe just rolling back the transaction?
Re: How to check errors of a mysql_query?
Posted: Wed Sep 16, 2009 5:15 pm
by jackpf
Yeah I know.
But...he said he wanted to check why a query was failing. That's the quickest way imo.

Re: How to check errors of a mysql_query?
Posted: Wed Sep 16, 2009 5:22 pm
by Mirge
jackpf wrote:Yeah I know.
But...he said he wanted to check why a query was failing. That's the quickest way imo.

+1
