sniperscope Posted December 24, 2008 Share Posted December 24, 2008 Hi guys could some tell me what is wrong with this code ? echo $query returns exactly what i want but when i check db, it update only one column which is flag column of last row of query. Here is the Query; mysql_select_db($database_deli24, $deli24); mysql_query($query) or die ("Error in query: $query"); $size = count($_POST['nick_name']); // find out how many records there are to update $i = 0; while ($i < $size) { //make a loop for number of records $name = $_POST['name'][$i]; $is_working = $_POST['is_working'][$i]; $start_hour = $_POST['start_hour'][$i]; $start_min = $_POST['start_min'][$i]; $finish_hour = $_POST['finish_hour'][$i]; $finish_min = $_POST['finish_min'][$i]; $flag = $_POST['asktoadmin'][$i]; $query = "UPDATE shukkin SET is_working='$is_working', name='$name', start_hour='$start_hour', start_min='$start_min', finish_hour='$finish_hour', finish_min='$finish_min', flag='$flag' WHERE name='$name' LIMIT 1"; echo "$i QUERY WAS = = =$query<br><br>"; ++$i; } mysql_close(); End this is result of echo $query UPDATE shukkin SET is_working='1', name='mike', start_hour='18', start_min='40', finish_hour='22', finish_min='40', flag='1' WHERE name='mike' LIMIT 1 if i run this query directly from phpmyadmin sql_also doesn't update without any error. Link to comment https://forums.phpfreaks.com/topic/138282-solved-why-this-query-doesnt-work/ Share on other sites More sharing options...
MasterACE14 Posted December 24, 2008 Share Posted December 24, 2008 add.. mysql_query($query) or die(mysql_error()); after $query... you're not even running the query O_o where you have the query at the top isn't going to work. It needs to be after $query. Link to comment https://forums.phpfreaks.com/topic/138282-solved-why-this-query-doesnt-work/#findComment-723002 Share on other sites More sharing options...
d.shankar Posted December 24, 2008 Share Posted December 24, 2008 Goodfinding MasterACE Link to comment https://forums.phpfreaks.com/topic/138282-solved-why-this-query-doesnt-work/#findComment-723010 Share on other sites More sharing options...
sniperscope Posted December 24, 2008 Author Share Posted December 24, 2008 Excelent, Excelent, Excelent. I just miss the point that i run the query after loop finished. So i took it into loop. Now works perfect. Link to comment https://forums.phpfreaks.com/topic/138282-solved-why-this-query-doesnt-work/#findComment-723014 Share on other sites More sharing options...
d.shankar Posted December 24, 2008 Share Posted December 24, 2008 Click "Topic Solved" please Link to comment https://forums.phpfreaks.com/topic/138282-solved-why-this-query-doesnt-work/#findComment-723146 Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 I don't see how this did not work from phpmyadmin. Link to comment https://forums.phpfreaks.com/topic/138282-solved-why-this-query-doesnt-work/#findComment-723147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.