Welcome to WebmasterWorld Guest from 54.167.83.224

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

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

Junior Member

5+ Year Member

joined:Apr 20, 2006
posts: 109
votes: 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?
9:26 am on Jan 28, 2013 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 20, 2006
posts: 109
votes: 0


never mind this question.. i realize the issue.. heeheheh... sorry..
1:12 pm on Jan 28, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


I'm guessing there was no id = '4' ? :-)
Here nor there, glad you got it sorted!
9:17 pm on Mar 3, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 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
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members