0

i have a small problem deleting from the data base that i have created using a form. this is the error that i am getting on the webpage

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id_no='806000169'' at line 1

and this the code that i have written to delete entities in my data base

<?php
session_start();


$coursecode=$_POST['code'];
$id=$_SESSION['username'];




$con = mysql_connect("$hostname","$username","$password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("$database", $con);

$sql="DELETE  FROM student_course WHERE course_code='$coursecode' ,id_no='$id'";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
require_once('students_status.php');
//echo "1 record added";

mysql_close($con)
?>

i can enter entities into the database but some how i just cannot delete using this code. can anyone help me out so that i can delete entities on the database?
thanks!!!

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by MrYrm
0

instead of:

$sql="DELETE FROM student_course WHERE course_code='$coursecode' , id_no='$id'"

try:

$sql="DELETE FROM student_course WHERE course_code='$coursecode' AND id_no='$id'"
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.