From: jim at bluedojo dot com
Operating system: WinXP
PHP version: 4.3.3
PHP Bug Type: MySQL related
Bug description: Updating single row in table causing all rows in table to be updated.

I have a table with ~2.2 million rows. Sometimes when I do an update to
one single row it will instead update ALL of the rows using the same
update, making the database totally useless. This happens every one in
about 500,000 updates to a single row.

I am running mysql 4.0.14 in WinXP. I am using PHP 4.3.3 to do the

I updated a column of a row of type "text" with the following data (The
string is quite long):

$buf = "KLUC 98.5, Las Vegas' #1 Hit Music Station local weather
KLUC Privacy Policy Terms of Use Agreement Employment EEO Policy EEO
Public File Report As the school year just gets started, 98.5 KLUC, Las
Vegas' #1 Hit Music Station asks you this.. Are you ready to PARTY!!! It's
the return of the High School Elimination . It's your opportunity to show
your school spirit and try to survive from being voted off. If you do,
your school will win a free party at Gameworks, and you never know what
KLUC has up it's sleeves. Can VoTech repeat as champions or will the
rookies, Liberty or Shadow Ridge be the ones to take it all. It's High
School Elimination 2 from the only station with all the school spirit,
98.5 KLUC, Las Vegas' #1 Hit Music Station. Click here to register and
vote! 98.5 KLUC, Las Vegas' #1 Hit Music Station is bringing yet another
huge KLUC concert to the Vegas Valley. Mack 10 live on-stage Thursday
September 18 at the House Of Blues. Keep it locked onto KLUC for you shot
to win. It's Mack 10 brought to you by Michelob, House Of Blues, and Las
Vegas' #1 Hit Music Station, 98.5 KLUC. Every week the 98.5 KLUC High
School Football Patrol pads up with live updates from the best games of
the week. Check out the football patrol in the stands for the Bishop
Gorman at Liberty and Canyon View at Shadow Ridge matchups. High School
Football Patrol only from Las Vegas' #1 Hit Music Station, 98.5 KLUC.
Every Monday - Friday, KLUC midday man Tim Stevens plays all your favorite
old school music during the Old School Lunch Hour at noon. Call in with
your requests and you may win lunch for (2) from Aloha Kitchen. 98.5 KLUC,
Las Vegas' #1 Hit Music Station is teaming up with Aquafina to spot you.
Listen to KLUC to find out where the Party Patrol will be with ice cold
Aquafina and KLUC prizes throughout the valley. If you pick an Aquafina
bottle with an X on it, you'll have the chance to win CD's, DVD's, PS2,
Xbox, and Gamecube games, and tons of other prizes. It's the Aquafina Get
Spotted contest with Aquafina and Las Vegas' #1 Hit Music Station, 98.5
KLUC. Training with Trejo Listen to the Morning Zoo M-F 5a-9a for a daily
update on Trejo's progress! The 98.5 KLUC Party Patrol is back for the
Summer of Jamz! Every Saturday night, Rayne and the KLUC Party Patrol load
up the Urban Suburban and will broadcast LIVE fron your living room with
awesome KLUC prizes like movie tickets, CD's, concert tickets, Wet N Wild
tickets, food and drinks and more and they could crash your crib! BEST OF
ALL, IT'S FREE! Click here to fill out the entry form and get ready,
because Saturday night, the Party Patrol could be knockin' on your front
door! From Las Vegas' #1 Hit Music Station, 98.5 KLUC! upcoming events
Tue. September 9 11:00pm Tim Stevens Studio 54 Wed. September 10 11:00pm
JB Baby's Thu. September 11 11:00pm Bo Jaxon Club Rio kluc's top 88
Results From :: 9.8.2003 1. Suga Suga Baby Bash 2. Get Low Lil Jon 3.
Can't Nobody Hold Us Down Christina/Lil Kim 4. PIMP(remix) 50Cent 5. Right
Thurrr Chingy 6. Shake Yo Tailfeather Nelly, P-Diddy 7. Thoing Thoing
R.Kelly 8. The Way You Move Outkast morning zoo poll The Bennifer (Ben
Affleck & J-Lo) are to be married this weekend. How long do you think this
marriage will last? 1 year 3 years 5 years Until J-Lo gets bored For
Eternity current results earlier poll results 288 people have taken this
poll 2003 KLUC / Infinity Radio Corp."

I am thinking something in the variable '$buf' is causing mysql to do
this. Some character (like single quote or weird character) in the update
is causing all the rows to be updated when only one row is supposed to be

Reproduce code:
Here is a sample SQL (cleaned up for easy reading):

$buf ="A long string";
$buf = addslashes($buf);
mysql_query("UPDATE page SET page_content = '$buf' WHERE page_id = 10");

Expected result:
It should only update a single row.

Actual result:
It updates all the rows in the database. Not good. :(

Edit bug report at [url][/url]
Try a CVS snapshot (php4): [url][/url]
Try a CVS snapshot (php5): [url][/url]
Fixed in CVS: [url][/url]
Fixed in release: [url][/url]
Need backtrace: [url][/url]
Try newer version: [url][/url]
Not developer issue: [url][/url]
Expected behavior: [url][/url]
Not enough info: [url][/url]
Submitted twice: [url][/url]
register_globals: [url][/url]
PHP 3 support discontinued: [url][/url]
Daylight Savings: [url][/url]
IIS Stability: [url][/url]
Install GNU Sed: [url][/url]