I'm getting an error as i'm trying to Insert Data From a Form Into a Database through PHP but i don't know whats wrong with my code..help

<? include("connection.php");
 
 mysql_query("insert into patient_information (ID,admission_ID,patient_ID,guardian_ID,admission_date,admission_time,patient_status,reason_for_status,referred_doctor_ID,referred_doctor_name,assigned_doctor_ID,assigned_doctor_name,department_ID,department_name,ward_ID,ward_no,room_ID,additional_notes) values('NULL','"$_POST[a_id]"','"$_POST[p_id]"','"$_POST[g_id]"','"$_POST[adm_d]"','"$_POST[adm_t]"','"$_POST[p_s]"','"$_POST[r_s]"','"$_POST[r_d_id]"','"$_POST[r_d_n]"','"$_POST[a_d_id]"','"$_POST[a_d_n]"','"$_POST[d_id]"','"$_POST[d_n]"','"$_POST[w_id]"','"$_POST[w_no]"','"$_POST[r_id]"','"$_POST[a_n]"')")or die(mysql_error());

echo $q;

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }


echo "<script type='text/javascript'>  alert('1 record is added'); </script> ";


?>

this is the error
Parse error: syntax error, unexpected T_VARIABLE in D:\xampp\htdocs\soomrof\u_task_4_1.php on line 3

plzzz someone help me plzzzzzzzzzzz

try to quote your post values like this:

'".$_POST['a_id']."'

means
your query should like this:

mysql_query("insert into patient_information (ID,admission_ID,patient_ID,guardian_ID,admission_date,admission_time,patient_status,reason_for_status,referred_doctor_ID,referred_doctor_name,assigned_doctor_ID,assigned_doctor_name,department_ID,department_name,ward_ID,ward_no,room_ID,additional_notes) values('NULL','".$_POST['a_id']."',..etc

or try to echo your query like:

$q="insert into ...."; //  your query
echo $q;

see that query and post here

:) thanku soooooo muchhhhhhhhhh it worksssssss GOD BLESS YOU !!!!!!!!!

thank you

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.