473,748 Members | 8,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($qu eryString, $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 3979
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
7153
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 example, I provide this sample (data_registre, data_ultima_connexio are the outputs of the SELECT).
0
2366
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 the table has a NOT NULL restriction on the field, the insert still completes successfully, but transforms the NULL value to an empty string. The preferred behavior would be for mysql to emit and error and not accept the attempt to set a NULL...
2
2413
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 time. However, I have just come across a problem with the new configuration that boggles my mind.... First some configuration data:
2
2470
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. Here it is: mySQL server: version "4.0.20-standard" on localhost hardware : 1.8 MHz Pentium 4 with 512 cache and 512 MB 266MHz RAM and 40 MB Matrox+ harddisk Here is the problem:
5
5137
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 However if I update any other column the syntax is fine
2
2522
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 Update statement. I have a sample code to reproduce my problem. To simplify the scenario I am trying to use Order related tables to explain a little better the tables i have to work with.
5
5606
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 uses very high volume DB transactions - in the order of tens of millions per day . . . Anyway, the current database which will remain nameless, but begins with O and rymes with debacle (sorta), has a problem with high volume work when it comes to...
0
2653
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 than this: update link_items set linksfti=to_tsvector('default', coalesce(name, '')
10
4589
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 these keys and after AD these keys, but I need make this in one stored procedure but show problems when run this. I can make this in one stored procedure? This is the estored procedure
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.