0

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

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Shanti C
0

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

Edited by Shanti C: n/a

This topic has been dead for over six months. 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.