473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Update statement causes mysql varchar field to be set to empty string

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 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 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

Mar 9 '06 #1
2 3960
On Wed, 08 Mar 2006 22:39:16 -0800, mark wrote:
$queryString = "UPDATE REGISTRATION SET passwd = '$pass'' WHERE id = 388";


Is it just a typo in your newsgroup post that you have two single quotes
after $pass or is that straight from the code?

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Mar 9 '06 #2
Andy,

I had a typo in my original post -- there is only a single quote after
the $pass variable.

The actual code is:

$queryString = "UPDATE REGISTRATION SET passwd = '$pass' WHERE id =
388";

Thanks for the good eye! ;)

Mar 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Harald Servat Gelabert | last post by:
Dear news-team I'm using MySQL 4.0.15a (with PHP 4.3.4rc1 and Apache 2.0.47 under FreeBSD). I'm having problems when updating a column of a table (it updates an extra column). As an...
0
by: Steven Hilton | last post by:
I am experiencing odd behavior, and I'm hoping someone can explain why it is behaving this way, and how to get around it... When I update a row in a table with a field's data set to NULL, but...
2
by: skidvd | last post by:
Hello: I have just recently converted to using the InnoDB table type so that I can enforce FOREIGN key constraints. I have been using MyISAM tables (accessed via JDBC) successfully for some...
2
by: ghasem | last post by:
Dear mySQL community, I have once again turned to the user groups for a problem I cannot solve myself! Atually, I have read all I can from the newsgroups on this but I could not solve it myself....
5
by: S.Patten | last post by:
Hi, I have a problem with updating a datetime column, When I try to change the Column from VB I get "Incorrect syntax near '942'" returned from '942' is the unique key column value ...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
5
by: Louis LeBlanc | last post by:
Hey folks. I'm new to the list, and not quite what you'd call a DB Guru, so please be patient with me. I'm afraid the lead up here is a bit verbose . . . I am working on an application that...
0
by: Justin Kennedy | last post by:
The short question is why does this: select to_tsvector('default', coalesce(name, '') ||' '|| coalesce(description, '') ||' '|| coalesce(keywords,'')) from link_items; give different results...
10
by: Ivan | last post by:
Hi to all !!! I have one stored procedure that update and delete rows in differents tables, but when I try of delete of the main table this show problems with primary and foreign key. I DROP...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.