0
votes

after submitting i get this 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 '.'died','MALE','A','everyday','waiting','for','you')' at line 2 ..

here is my code

extract($_POST);
if(isset($add)){
$sql = "INSERT INTO `tbl_patients` (`dateadd`,`pfname`,`plname`,`pdob`,`address`,`pgender`,`pbtype`,`pheight`,`pweight`,`fallergy`,`mallergy`)
    VALUES ('$date','$fname','$lname','$dob'.'$address','$gender','$bloodtype','$hgt','$wgt','$falrgs','$malrgs')";
3

3 Answers

2
votes

You are using dot(.) here '$dob'.'$address', should be comma(,) try to replace

'$dob'.'$address',

to

'$dob','$address',

so full query :-

$sql = "INSERT INTO `tbl_patients` (`dateadd`,`pfname`,`plname`,`pdob`,`address`,`pgender`,`pbtype`,`pheight`,`pweight`,`fallergy`,`mallergy`) VALUES('$date','$fname','$lname','$dob','$address','$gender','$bloodtype','$hgt','$wgt','$falrgs','$malrgs')";
1
votes

, is missing.

'$dob','$address'
0
votes

It should be -

"INSERT INTO `tbl_patients` (`dateadd`,`pfname`,`plname`,`pdob`,`address`,`pgender`,`pbtype`,`pheight`,`pweight`,`fallergy`,`mallergy`)
VALUES ('$date','$fname','$lname','$dob','$address','$gender','$bloodtype','$hgt','$wgt','$falrgs','$malrgs')

There was a . instead of ,