I have come across a problem that has me baffled.
I am using PHP with MySQL 4.1.14. Whenever I execute an update statement against a specific table, some of the varchar fields do not get set to the new values, but get set to empty strings instead.
I have simplified the code down to updating a single column in the table, but the same results happen when updating just the single column.
Here is the stripped down code which causes the problem:
$queryString = "UPDATE REGISTRATION SET passwd = '$pass' WHERE id = 388";
$db = mysql_connect("hostname", "user", "pass");
mysql_select_db("CUSTOMER", $db) or die(mysql_error());
mysql_query($queryString, $db) or die(mysql_error());
Printing the query string after executing mysql_query shows the following query:
UPDATE REGISTRATION SET passwd = 'test' WHERE id = 388
This query updates the column successfully when run directly through phpMyAdmin. When run through PHP using the code above then the column is set to an empty string value.
There is no error returned if I call mysql_error() nor is there any unusual info returned from mysql_info() (other than it is telling me that 1 row was affected).
Does anyone have any ideas what the underlying problem is on this one? Could be an attribute of the database table or columns that would cause this behavior? I have racked my brain for a while over this problem. 😕
Any insight would be appreciated!
Thanks,
Mark