$grade=$_POST["grade"];
$stream=$_POST["stream"];
$a=='A';

$query="delete * from class where grade_id='$grade' and stream='$stream' and class_name='$a'";
$result=mysql_query($query);
if($stream==null)(
$query1="insert into class values(null,'$a','$grade','null')";
$result=mysql_query($query1);
}else(
$query1="insert into class values(null,'$a','$grade','$stream')";
$result=mysql_query($query1);
)

in this code runs .the code which color in red is occur error . please someone can tell me the reason for that?

on the last value you are inserting you have: 'null' Get rid of those apostrophes. It should be just NULL. Also, I suggest you list the fields you are inserting the data into: $query1="INSERT INTO `class`(`field1`,`field2`,`field3`,`field4`) VALUES(NULL,'$a','$grade', NULL)"; Replace the field# with the actual names of the fields in your db table.

if($stream==null)(
$query1="insert into class values(null,'$a','$grade','null')";
$result=mysql_query($query1);
}else(
$query1="insert into class values(null,'$a','$grade','$stream')";
$result=mysql_query($query1);
)
in this code "if" condition check that the $stream==null

what happen is when that $ stream null ,in that class table last field is $stream .I wanted to fill last column in string null in the class table.so what i want to do

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.