Welcome to WebmasterWorld Guest from 54.160.131.144

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

     

camilord

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

5+ Year Member



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

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

5+ Year Member



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

coopster

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

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



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

Matthew1980

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

WebmasterWorld Senior Member 5+ Year Member



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