Genesis730 Posted April 2, 2011 Share Posted April 2, 2011 I'm trying to update every record where one field in a row is less than the other. The code gets each row i'm looking for and sets up the query right, I hope I combined the entire query into one string each query seperated by a ; so it's like UPDATE `table` SET field2= '1' WHERE field1= '1';UPDATE `table` SET field2= '1' WHERE field1= '2';UPDATE `table` SET field2= '1' WHERE field1= '3';UPDATE `table` SET field2= '1' WHERE field1= '4';UPDATE `table` SET field2= '1' WHERE field1= '5'; this executes properly if i run the query in phpMyAdmin, however when I run the query in PHP, it does nothing... Any advice? Link to comment https://forums.phpfreaks.com/topic/232489-phpmyadmin-query-works-but-php-query-doesnt/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 2, 2011 Share Posted April 2, 2011 From the mysql_query() documentation - mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier. Link to comment https://forums.phpfreaks.com/topic/232489-phpmyadmin-query-works-but-php-query-doesnt/#findComment-1195866 Share on other sites More sharing options...
Genesis730 Posted April 2, 2011 Author Share Posted April 2, 2011 So is there any way I can change multiple rows at once? Link to comment https://forums.phpfreaks.com/topic/232489-phpmyadmin-query-works-but-php-query-doesnt/#findComment-1195895 Share on other sites More sharing options...
Genesis730 Posted April 2, 2011 Author Share Posted April 2, 2011 Nevermind, I got it Link to comment https://forums.phpfreaks.com/topic/232489-phpmyadmin-query-works-but-php-query-doesnt/#findComment-1195946 Share on other sites More sharing options...
sasa Posted April 3, 2011 Share Posted April 3, 2011 UPDATE `table` SET field2= '1' WHERE field1 IN ('1', '2', '3', '4', '5') Link to comment https://forums.phpfreaks.com/topic/232489-phpmyadmin-query-works-but-php-query-doesnt/#findComment-1196132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.