slaterino Posted January 27, 2009 Share Posted January 27, 2009 I am having troubles with what I thought was a simple query. I am hoping to have a form where I can edit data from my MySQL database. However, the page keeps showing as blank. I have an index page with dynamic links such as 'class_edit.php?cl_ID=2'. They then go to this page but it's currently showing completely blank. This is the code on the page. If anyone can see anything on this page that might be causing problems could they please let me know. Thanks! <?php error_reporting(E_ALL); ini_set('display_errors', '1'); include '../library/config.php'; include '../library/opendb.php'; $cl_ID = $_GET['cl_ID']; if(isset($_POST['submit'])) { $cl_course = addslashes($_POST['cl_course']); $cl_day = addslashes($_POST['cl_day']); $result = mysql_query("UPDATE classes SET cl_course='$cl_course', cl_day='$cl_day' WHERE cl_ID='$cl_ID' ",$conn); } elseif($cl_ID) { $result = mysql_query("SELECT * FROM classes WHERE cl_ID='$cl_ID' ",$conn); while($myrow = mysql_fetch_assoc($result)) { $cl_course = $myrow["cl_course"]; $cl_day = $myrow["cl_day"]; ?> <form method="post" action="<?php echo $PHP_SELF ?>"> <table> <input type="hidden" name="cl_ID" value="<? echo $myrow['cl_ID']?>"> <tr> <td>Course:</td><td><input name="cl_course" size="40" maxlength="255" value="<? echo $cl_course; ?>" /></td></tr> <tr> <td>Day: </td><td><input name="cl_day" size="40" maxlength="255" value="<? echo $cl_day; ?>" /></td></tr> </table><br /> <div align="center"><input type="submit" name="submit" value="Update Class" /></div> </form> <? } } ?> Quote Link to comment Share on other sites More sharing options...
rubing Posted January 27, 2009 Share Posted January 27, 2009 If cl_id is a number than you don't need quotes around it in your query. that's probably the problem...sql trying to compare a string to an integer Try that and then if that doesn't work start profiling it by throwing some echo statements in there??? <?php error_reporting(E_ALL); ini_set('display_errors', '1'); include '../library/config.php'; include '../library/opendb.php'; $cl_ID = $_GET['cl_ID']; if(isset($_POST['submit'])) { $cl_course = addslashes($_POST['cl_course']); $cl_day = addslashes($_POST['cl_day']); $result = mysql_query("UPDATE classes SET cl_course='$cl_course', cl_day='$cl_day' WHERE cl_ID='$cl_ID' ",$conn); } elseif($cl_ID) { $result = mysql_query("SELECT * FROM classes WHERE cl_ID='$cl_ID' ",$conn); while($myrow = mysql_fetch_assoc($result)) { $cl_course = $myrow["cl_course"]; echo $cl_course; $cl_day = $myrow["cl_day"]; echo $cl_day; ?> <form method="post" action="<?php echo $PHP_SELF ?>"> <table> <input type="hidden" name="cl_ID" value="<? echo $myrow['cl_ID']?>"> <tr> <td>Course:</td><td><input name="cl_course" size="40" maxlength="255" value="<? echo $cl_course; ?>" /></td></tr> <tr> <td>Day: </td><td><input name="cl_day" size="40" maxlength="255" value="<? echo $cl_day; ?>" /></td></tr> </table><br /> <div align="center"><input type="submit" name="submit" value="Update Class" /></div> </form> <? } } ?> Quote Link to comment 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.