scott.stephan Posted September 28, 2009 Share Posted September 28, 2009 //Send off the Rec to be written $qry_new_rec = "INSERT INTO scores(grade,section,group,group_name,year,semester,u_id) VALUES($grade,$section,$g_num,$g_name,$year,$semester,$u_id)"; $result = @mysql_query($qry_new_rec); echo "Rec written?"; Assuming that all of those variables are named correctly and have values, why won't this write a record? I feel like I'm overlooking something major and I just cant see it. This runs fine without any errors, but it doesn't create a new record. Here;s the rest of the (sloppy sloppy) code: require_once('config.php'); //DB settings ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); /* Open DB Connect */ //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } if($link){ echo "Successful DB connect"; } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } /*END DB CONNECT */ /*Nab the POST data. Yes, I know this is sloppy, but it'll do for Alpha */ $semester=ucfirst($_POST['semester']); //Move to ALLCAPS to ascertain u_id predicatbility. $grade=$_POST['grade']; $section=$_POST['section']; $g_num=$_POST['g_num']; $g_name=$_POST['g_name']; $year=date('y'); //Compile a unique ID for a group: GradeSectionNumberSemesterYear, i.e 612F09 for Grade 6 Section 1 Group 2 Fall of 2009 $u_id=$grade.$section.$g_num.$semester[0].date('y'); echo "Semester: $semester <br/> Grade: $grade <br/> Section: $section <br/> Group Num: $g_num <br/> Group Name: $g_name Unique ID: $u_id"; //Send off the Rec to be written $qry_new_rec = "INSERT INTO scores(grade,section,group,group_name,year,semester,u_id) VALUES($grade,$section,$g_num,$g_name,$year,$semester,$u_id)"; $result = @mysql_query($qry_new_rec); echo "Rec written?"; Link to comment https://forums.phpfreaks.com/topic/175777-no-error-but-not-inserting-a-new-record/ Share on other sites More sharing options...
trq Posted September 28, 2009 Share Posted September 28, 2009 Remove the @ error suppressor and you might actually see some errors. The words group and year are reserved so should be renamed or at very least escaped using `backticks`. Link to comment https://forums.phpfreaks.com/topic/175777-no-error-but-not-inserting-a-new-record/#findComment-926295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.