php - using form variables for mysql query -
i'm trying fetch result mysql table using 2 form variables namely $sessionid , $semesterid. used following code , seems have error in sql syntax
<?php ... mysql_select_db($database_conncheportal, $conncheportal); $query_rsregcourses =sprintf("select * vw_reg vwr vwr.sessionid=%s , vwr.semesterid=%s",$sessionid,$semesterid); $rsregcourses = mysql_query($query_rsregcourses, $conncheportal) or die(mysql_error()); $row_rsregcourses = mysql_fetch_assoc($rsregcourses); $totalrows_rsregcourses = mysql_num_rows($rsregcourses); print_r($query_rsregcourses); die; ... ?> i tried running query , have following error report
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'and vwr.semesterid=' @ line 1 thanks
i think should surround variable single quotes '' please change follow
"select * vw_reg vwr vwr.sessionid='%s' , vwr.semesterid='%s'"
Comments
Post a Comment