dolcezza Posted January 6, 2008 Share Posted January 6, 2008 I am not able to test my code from where i am now, and I am not sure why my editor is underlining this code. Any chance someone may be willing to help me find the issue? It's underlining the if ($time) { but obviously that doesn't always mean it's not before or after. for ($loop=1;$loop<=3;$loop++) { $time = $_POST['time-'.$loop]; if ($time) { $scheduleinsert = "INSERT INTO schedules (eventid, time, grades, room, notes) VALUES ('$eventid', '$time', '$grades', '$room', '$notes')"; $schedule_result=mysql_query($scheduleinsert); Thanks, any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/ Share on other sites More sharing options...
interpim Posted January 6, 2008 Share Posted January 6, 2008 are you closing the if ($time) and for loops?... Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/#findComment-431681 Share on other sites More sharing options...
dolcezza Posted January 6, 2008 Author Share Posted January 6, 2008 yes... for ($loop=1;$loop<=3;$loop++) { $time = $_POST['time-'.$loop]; if ($time) { $scheduleinsert = "INSERT INTO schedules (eventid, time, grades, room, notes) VALUES ('$eventid', '$time', '$grades', '$room', '$notes')"; $schedule_result=mysql_query($scheduleinsert); } } Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/#findComment-431683 Share on other sites More sharing options...
marcus Posted January 6, 2008 Share Posted January 6, 2008 <?php for ($i = 1; $i <= 3; $i++) { $time = $_POST['time-' . $i]; if ($time) { $scheduleinsert = "INSERT INTO `schedules` (`eventid`, `time`, `grades`, `room`, `notes`) VALUES ('" . $eventid . "', '" . $time . "', '" . $grades . "', '" . $room . "', '" . $notes . "')"; $schedule_result = mysql_query($scheduleinsert); } } ?> Just make sure you have the other variables defined. Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/#findComment-431684 Share on other sites More sharing options...
dolcezza Posted January 6, 2008 Author Share Posted January 6, 2008 I changed it to the following, realizing I had to add the loop part to those variables too, but I'm still getting the same thing. It says parse error: expecting T_string or T_variable or T_NUM_STRING on line 21 for ($i = 1; $i <= 3; $i++) { $time = $_POST['time-' . $i]; $grades = $_POST['grades-' . $i]; $room = $_POST['room-' . $i]; $notes = $_POST['notes-' . $i]; if ($time) { $scheduleinsert = "INSERT INTO `schedules` (`eventid`, `time`, `grades`, `room`, `notes`) VALUES ('" . $eventid . "', '" . $time . "', '" . $grades . "', '" . $room . "', '" . $notes . "')"; $schedule_result = mysql_query($scheduleinsert); } } Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/#findComment-431686 Share on other sites More sharing options...
Ken2k7 Posted January 6, 2008 Share Posted January 6, 2008 Where's line 21? Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/#findComment-431724 Share on other sites More sharing options...
dolcezza Posted January 6, 2008 Author Share Posted January 6, 2008 line 21 is the "the if (time) {" Quote Link to comment https://forums.phpfreaks.com/topic/84704-insert-inside-for-loop/#findComment-431990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.