|
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]
|