0

I get an error with my PHP code when updating the table patient. I cannot find the problem.

Here is my error:

Verification 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 '1' at line 1

<?php
$edit = mysql_query("UPDATE `patient` SET `date`='$date', `fname`='$fname', `lname`='$lname', `birthday`='$dob', `address`='$address', `work`='$work', `civil`='$civil', `gender`='$sex', `btype`='$bloodtype', `height`='$hgt', `weight`='$wgt', `fallergy`='$fallergy', `mallergy`='$mallergy' WHERE `patientid`='$vara'");
$result = mysql_query($edit) or die("Verification Error: " . mysql_error());
6
  • $edit = mysql_query("UPDATE patient SET date='$date', fname='$fname', lname='$lname', birthday='$dob', address='$address', work='$work', civil='$civil', gender='$sex', btype='$bloodtype', height='$hgt', weight='$wgt', fallergy='$fallergy', mallergy='$mallergy' WHERE patientid='$vara'"); $result = mysql_query($edit) or die("Verification Error: " . mysql_error()); Commented Mar 1, 2015 at 5:34
  • use echo $edit; after your query in $edit .And copy paste the query string in Database, phpmyadmin. And tell us what is error. Commented Mar 1, 2015 at 5:36
  • 1
    Next time you create a question or answer, please put more effort into it. We should not have to clean up after you. Commented Mar 1, 2015 at 5:39
  • sorry . i dont know how to that way. Commented Mar 1, 2015 at 5:42
  • @EverythingRichardify , hi , I asked : use echo $edit; after your query in $edit .And copy paste the query string in Database, phpmyadmin. And tell us what is error. Commented Mar 1, 2015 at 5:42

1 Answer 1

2

You are calling mysql_query twice; the second time you pass the result, of the first call, into it as an argument. That is not how mysql_query works. The SQL should just be a string:

$edit = "UPDATE `patient` SET `date`='$date', `fname` ...";
$result = mysql_query($edit) or die("Verification Error: " . mysql_error());

We cannot see the rest of your code, so we do not know if there are more problems, but this should fix the problem in your question.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.