-1

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 '','')' at line 2

and this my code what is wrong ??

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi,'$comment')";
Tharif
  • 13,794
  • 9
  • 55
  • 77
cullen
  • 3
  • 2
  • You have a typo at end of your query string: `'$dr_npi','$comment'` – vhu Jul 16 '15 at 08:29
  • 2
    As always, post about [preventing SQL injections](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1) is relevant here. – vhu Jul 16 '15 at 08:31
  • Apropos: http://powerfield-software.com/?p=1202. It's a good idea to refrain from posting questions regarding SQL syntax errors until you've seen the _actual_ SQL code being executed (rather than the code that just constructs it). – paxdiablo Jul 16 '15 at 08:34

4 Answers4

1

You missed qoute ' here: '$dr_npi,'$comment' should be like this: '$dr_npi','$comment'


And full fixed query:

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')";
0

You missed a quote here '$dr_npi,'$comment', working query is;

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')"
Shehary
  • 9,926
  • 10
  • 42
  • 71
0

Change the query as :

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')";
Tharif
  • 13,794
  • 9
  • 55
  • 77
-1

If you want to use the SQL with PHP correctly, you must combine the ' and "

<?php
$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('".$agent_name."','".$date."','".$p_title."','".$p_fname."','".$p_lname."','".$p_number."','".$address."','".$city."','".$state."','".$postal_code."','".$DoB."','".$plan."','".$mcn."','".$dr_title."','".$dr_fname."','".$dr_lname."','".$status."','".$dr_npi."','".$comment."')";
?>

I wish this is what you need

Kyto
  • 181
  • 3
  • 12