MySQL query problems

From: Date: Wed, 17 Apr 2002 11:48:47 +0000
Subject: MySQL query problems
Groups: php.general 
Request: Send a blank email to php-general+get-93316@lists.php.net to get a copy of this message
Hi I wonder if someone can help: I wrote a little generic table browse/searc/edit/add tool that simply takes the name of the db, username/password and tablenames as arguments and then displays the table contents in rows and places an "edit" link next to each row that in turns open a page with text areas filled with the current data for each field, when submit, it "updates" the table with whatever is in the textareas at the time. Now, this morning when I used this tool ( after many successfull tests), I edited an entry in a table with about 2000 rows but to my horror, when I checked back, it set ALL the rows to contain the same data, typically what happens when you do a " update table set xxx=yyy " and you ommit to say for which row or id. Now I KNOW I have a "where id=$id" at the end of my generated sql, yet it is as if it lost it. So, to get to my question, how can I do a "test" sql execution on a table, and then , only when the expected result is returned, should the actual sql be executed. Obviously this is not needed for simple "selects" as they don't change data in the table, but the same would be needed for "delete from". Basically, if I could check the mysql_num_rows output of the query ( for updates and deletes as I use them, I could always check to make sure that it is only 1), and only if it is 1, should the query actually take place. I hope I have stated the question clear enough, if not, please mail me and I'll try to elaborate. Thanks

« previous php.general (#93316) next »