You are here: Re: How to debug PHP's mysql_query() function? « PHP Programming Language « IT news, forums, messages
Re: How to debug PHP's mysql_query() function?

Posted by Justin Koivisto on 11/03/05 00:38

John Moore wrote:
> Hi
>
> I posted three days ago about a function I wrote which kept refusing
> to run a mysql_query.
>
> Well I did away with the function, and hard coded the variables into
> the query itself. Here's what I have now:
>
> mysql_query("UPDATE about SET category_id = 58 WHERE about_id = 5") or
> die('error: ' . mysql_error());
>
> Just running mysql_query, with no logic, I still dont get an update,
> and the script doesn't die. What other things should I be looking at?
>
> Here's another variation of the same thing I've tried:
>
> mysql_query("UPDATE about SET category_id=60 WHERE about_id=5") or
> trigger_error("SQL", E_USER_ERROR);
>
> I've also done: $update = mysql_query("Blah blah blah"); and testing
> $update gives me nothing. No errors, no update.

after the query, run something like:
$rows = mysql_affected_rows()

if var_dump(mysql_query(...)) shows boolean true, then the query was a
success, then if $rows > 0, something was changed in the database, if
-1, the query failed, and 0 indicates a successful query with nothing
updated. if 0, perhaps the row already had those values or no rows have
the about_id = 5...

Also, I have a tendency to include the link identifier when using the
database functions just so that I know exactly which connection I am
working with (even if there is only one in the script) - it just removes
some more unknowns for debug time.

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация