salewit - 5:12 pm on Apr 19, 2011 (gmt 0)
This is driving me crazy. This is a routine that counts the number of items each vendor has, and stores it in another table.
Here's part of the code
$result = mysql_query("SELECT count(*) from inventory WHERE mfg like '".$row['vendorid']."';");
$count = mysql_fetch_row($result);
echo $count; # Properly returns 11
$j = "UPDATE catcount SET count = " . $count . " WHERE name LIKE '" . $row['vendorid'] . "' LIMIT 1;";
echo $j; # Properly returns UPDATE catcount SET count = 11 WHERE name LIKE "ri" LIMIT 1;
$result = mysql_query($j);
1) When I run this and look in catcount, "ri" count becomes 0 every time.
2) If I copy and paste that update statement directly into phpmyadmin, "ri" then becomes 11 as it should have in my script.
3) If I run my script again, it knocks out the 11, and it becomes 0 again. This happens on only 3 o4 fields out of about 100 vendors which really makes it confusing as to why it's not working on just a few random ones.