Weird update problem..
| From: | Ryan S | Date: | Mon, 26 May 2008 04:53:13 +0000 |
| Subject: | Weird update problem.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-274684@lists.php.net to get a copy of this message | ||
This is really weird... i have tried the same exact code in phpmyadmin and it works like a charm,
but when i run the script... no errors then i go to phpmyadmin and nothing has changed :(
this is the code:
============================================================================
$how_many_to_update=count($cardno_array);
// update the cards status to sent
for($i=0;$i<$how_many_to_update;$i++)
{
$update_sql="update greetings set is_sent=1 where
cardno='".$cardno_array[$i]."' and
rand_str='".$rand_str_array[$i]."' LIMIT 1";
$result = mysql_query($sql_1);
$num_rows1 = mysql_num_rows($result);
if(!$result || $num_rows1==0){echo "Error: unable to update sent greetings";exit;}
echo "updating<br>$update_sql<br>";
}
=========================================================================
In the second last line you can see i have an echo statement... the SQL thats outputted from there
works perfectly in phpmyadmin...
any idea whats wrong?
Slightly OT, any better way to run the multiple updates needed above than instead of running the
update query in a loop?
I searched google and the best i could find was the IN() for mySql... but that does not take 2
parameters (eg: cardno and rand_str) it would work just on card_no like this
in('14','34')
Thanks!
R