for some reason i am getting an error with my query statements here is my code
if ($_GET['mode'] == 'edit')
{ $c=$_GET['coursecode'];
echo"$c";
// editing an existing entity
// check for value of id
if (!$_GET['coursecode'])
{
echo "error: no coursecode specified, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
exit;
}
if (!$_POST['submit'])
{
// first access to form
// checking if the record is in the database
$query = "SELECT * FROM courses WHERE course_coode='$_GET[coursecode]'";
if (!$result=mysql_query($query))
{
echo '<p>nice</p>';
echo "error: user with id {$_GET['coursecode']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue </a>";
exit;
}
else
{
echo 'good shit';
$row = mysql_fetch_assoc($result);
extract($row);
$_POST['coursecode']=$course_code;
$_POST['coursename']=$course_name;
$_POST['description']=$course_description;
}
print_form();
}
// retrieve recored
//$query = "SELECT * FROM courses WHERE course_coode =$_GET['coursecode']";
//$result = ...;
// if record does not exist
/* if (... record not found ...)
{
echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
exit;
}
*/
// put existing record into $_POST
/* $_POST['name'] = $row[0];
$_POST['id'] = $row[1];
*/
//$_POST['name'] = "user";
//$_POST['id'] = "1234";
if ($_POST['submit'] == 'Save')
{
// user clicked save
// validate submitted data
$messages = validate_input();
if (count($messages) > 0)
{
// invalid data, print form for resubmission
print_form($messages);
}
else
{
// data was good, update entry
/* code to save entry */
$coursecode=$_POST['coursecode'];
$coursename=$_POST['coursename'];
$level=$_POST['level'];
$optionnumber=$_POST['option_no'];
$description=$_POST['description'];
$comp=$_POST['comp'];
$sem_no=$_POST['sem_no'];
$credits=$_POST['credits'];
$con = mysql_connect("$hostname","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$database", $con);
$sql="UPDATE courses SET course_name=$coursename,level_no=$level,option_no=$optionnumber,compulsory=$comp,
sem_no=$sem_no,course_description=$description,credits=$credits WHEREcourse_code=$coursecode ";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
//quire_once('courses.php');
//echo "1 record added";
echo "user {$_POST['coursecode']} updated, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
mysql_close($con);
}
}
else
{
// user clicked cancel (catch all)
echo "operation cancelled, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
}
}
can someone help me with the query statement in line 19 please since with the flags that i have i am only getting "nice "on the screen which shows me that the query statement is wrong for what reason idk.
thanks