Mysql UPDATE problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dcahrakos
Forum Newbie
Posts: 11
Joined: Mon Sep 26, 2005 6:52 pm

Mysql UPDATE problem

Post by dcahrakos »

Well, im working with a forum that probably not many people heard of, but that doesnt matter...anyway, im trying to do this, but it doesnt work

Code: Select all

mysql_query("UPDATE categories SET id='$cid', name='$cname', minpow='$cminpow' WHERE id=$id") or print mysql_error();
well, it says it works, but it doesnt actually update anything...can anyone shed some light on this mysterious problem? cause technically it should work, but I cant figure it out for the life of me, all variables are declared, and everything, so there shouldnt be a problem.

Thanks in advance.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

emit the query string to see if the string itself is correct for what you want to accomplish.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

This probably isn't the case, but double check that what you're trying to update is actually there. I spent about an hour trying to figure out this exact same problem and I finally realized that I called the update before the insert. It never occurred to me because the update was physically below the insert in a separate function. ^^;
omega-systems
Forum Newbie
Posts: 14
Joined: Tue Sep 27, 2005 5:01 am
Contact:

Re: Mysql UPDATE problem

Post by omega-systems »

Fot this type of SQL statements, mysql_query() returns TRUE on success and FALSE on error. A non-FALSE return value means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows.

Regards,
Michael.

Project Manager
Omega Systems Ltd
Email: info@omega-systems.biz
ICQ: 264962449
MSN: omega-systems@hotmail.com
AIM: OmegaSys Ltd
Post Reply