Hi, I can't figure out why this isn't working. I'm trying to loop through an array and do a mysql update. However, it doesn't work.
I tried using prepared statements to avoid using a loop but there doesn't seem to be a way to use 'LIKE' and a wildcard together. I also tried using PHP to load my txt file to update it that way, but, once again, my server is timing out. Now I'm forced to, once again, use a counting system and url loaders in Flash. Everything on the Flash side is working perfectly. I post a long string that's colon delimited and explode it in PHP. If I comment out the update statement in my PHP, everything works perfectly. The problem seems to be with my actual update statement, but I can't seem to figure out what's wrong with it. Can anyone offer any insight? Thanks!
Code:
for($i = 0; $i < $len; ++$i)
{
$param = $array[$i] . '%';
$query = "UPDATE `$table` SET `bool` = '$bool' WHERE `user` LIKE '$param' LIMIT 1";
$result = mysql_query($query);
if (mysql_affected_rows() === 0)
{
mysql_free_result($result);
$result = mysql_query("INSERT INTO `$table` (id, user, bool) VALUES ('', '" . $array[$i] . rand(10, 50) . "', '$bool')");
}
}
Comment