homepage Welcome to WebmasterWorld Guest from 54.204.94.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php + mysql : update with values but no rows affected. why?
camilord




msg:4539782
 9:23 am on Jan 28, 2013 (gmt 0)

this is my table:
mysql> desc app_agents;
+----------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+----------------+
| id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| app_id | bigint(20) unsigned | NO | | 0 | |
| agents_name | varchar(80) | YES | | NULL | |
| contact_person | varchar(80) | YES | | NULL | |
| mail_address | text | YES | | NULL | |
| postcode | varchar(10) | YES | | NULL | |
| street_address | text | YES | | NULL | |
| phone | varchar(24) | YES | | NULL | |
| mobile | varchar(24) | YES | | NULL | |
| fax | varchar(24) | YES | | NULL | |
| email | varchar(128) | YES | | NULL | |
| website | varchar(250) | YES | | NULL | |
+----------------+---------------------+------+-----+---------+----------------+
12 rows in set (0.00 sec)

mysql> UPDATE `app_agents` SET `agents_name` = 'd asd adsad ada das', `contact_person` = ' ', `mail_address` = ' ', `postcode` = '0', `street_address` = ' ', `phone` = ' ', `mobile` = ' ', `fax` = ' ', `email` = ' ', `website` = ' ' WHERE `id` = '4'
-> ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

mysql>


this is my sql statement:
UPDATE `app_agents` SET `agents_name` = 'd asd adsad ada das', `contact_person` = ' ', `mail_address` = ' ', `postcode` = '0', `street_address` = ' ', `phone` = ' ', `mobile` = ' ', `fax` = ' ', `email` = ' ', `website` = ' ' WHERE `id` = '4'

why there's no affected rows? how come?

 

camilord




msg:4539783
 9:26 am on Jan 28, 2013 (gmt 0)

never mind this question.. i realize the issue.. heeheheh... sorry..

coopster




msg:4539832
 1:12 pm on Jan 28, 2013 (gmt 0)

I'm guessing there was no id = '4' ? :-)
Here nor there, glad you got it sorted!

Matthew1980




msg:4550722
 9:17 pm on Mar 3, 2013 (gmt 0)

Hello everyone!

@Camilord: in the WHERE clause, you've got that as 'id', and it's down as a bigint, and I can't help but notice, so I thought I'd point it out: you're doing the update and turning it into a string - with the help of those single quotes.

Addressing updates using strings & asking for int's isn't really good practice, just knock the single quotes off, and the sql engine will treat that as the (big)int as it's intended to be.

Sorry to be a bore :)

But yes, like @coopster, I'm guessing that number 4 wasn't there. We've all done that before ;)

Cheers,
MRb

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved