mtvaran Posted November 3, 2010 Share Posted November 3, 2010 cud any1 tell me why this happens? when i run SOME of the php script using localhost, it says APACHE HTTP SERVER STOP WORKING Link to comment https://forums.phpfreaks.com/topic/217692-why-is-this-error-making/ Share on other sites More sharing options...
The Little Guy Posted November 3, 2010 Share Posted November 3, 2010 What is the code that you are running? Link to comment https://forums.phpfreaks.com/topic/217692-why-is-this-error-making/#findComment-1130025 Share on other sites More sharing options...
mtvaran Posted November 3, 2010 Author Share Posted November 3, 2010 well i have a task which is, i have two table in my database which are student (StudentID, StudentName)& course(CourseID, CourseName). i have displayed the field st_id from student (drop-down list) & course_id from course (multi select list). now i need to insert into another table called take which contain the feild StudentID and CourseID. so i have to select one st_id and one or more course_id then submit. there is the code for that so cud you pls check it 4 me. ?php $result = mysql_query("SELECT * FROM course") or trigger_error('MySQL error: ' . mysql_error()); echo '<select name ="cid[]" multiple="multiple" size="10">'; while($row = mysql_fetch_array($result)) { echo '<option value="' . $row['CourseID'] . '">' . $row['CourseName'] . '</option>'; } echo '</select>'; // ---------------- $result = mysql_query("SELECT * FROM student") or trigger_error('MySQL error: ' . mysql_error()); echo '<select name="sid">'; while($row = mysql_fetch_array($result)) { echo '<option value="' . $row['StudentID'] . '">' . $row['StudentName'] . '</option>'; } echo '</select>'; // ---------------- if (!empty($_POST['sid']) && !empty($_POST['cid'])) { $student = mysql_real_escape_string($_POST['sid']); $sql = "INSERT INTO take (StudentID, CourseID) VALUES"; foreach ($_POST['cid'] as $key => $course) { $sql .= ($key != 0) ? ", " : " "; $sql .= "('" . $student . "', '" . mysql_real_escape_string($course) . "')"; } $query = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error()); if (mysql_affected_rows($query) > 0) { echo mysql_affected_rows($query) . ' rows added.'; } } ?> Link to comment https://forums.phpfreaks.com/topic/217692-why-is-this-error-making/#findComment-1130032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.