Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- UPDATE refuses to update in php, but does in phpadmin


rocknbil - 5:11 pm on Apr 20, 2011 (gmt 0)


It might be that count is a mysql function (you're using it previously), and you are referencing the field count literally - it may conflict. Backtick your table object names:

$j = "UPDATE `catcount` SET `count` = " . $count[0] . " WHERE `name` = '" . $row['vendorid'] . "' LIMIT 1;";

Other ideas: what happens when you do this?

$result = mysql_query($j) or die("Cannot update record");
echo "Result $result";

It should echo "Result true";

What is the data type of the field "count"? Guessing it's numeric as you don't have it quoted (which should be fine . . . )

What's the possibility you have two records with the value ri?

The limit clause is not (should not be) needed, and like is less efficient than = if it's an exact match, but you said you already tried that.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4300520.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com