Reputation: 75
I have a simple php error coming up of which i cannot find the solution to. I inserted in the following code:
<?php
session_start();
require_once '../includes/db.php';
$address1 = $_REQUEST["address1"];
$address2 = $_REQUEST["address2"];
$city = $_REQUEST["city"];
$postcode = $_REQUEST["postcode"];
mysql_query("UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."')")
or die(mysql_error());
?>
This code gives me the following 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 ')' at line 1
Line 1 is the following in which i think it has nothing to do with the sql statement:
<?php
session_start();
?>
Thanks everyone! :)
Upvotes: 1
Views: 118
Reputation: 213
I think you've forgotten to place a semicolon at the end?
the right one below:
mysql_query(" UPDATE customers SET address1='$address1', address2='$address2',city='$city', postcode='$postcode' WHERE username ='". $_SESSION['username']."'");
Upvotes: 0
Reputation: 13511
Change that line:
mysql_query("UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."')")
to that
mysql_query("UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."'")
You have an extra right parenthesis in the query.
Upvotes: 5
Reputation: 12586
You have a )
in the end of the query that's not supposed to be there.
mysql_query("UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."'")
Upvotes: 3
Reputation: 227240
mysql_query("UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."')") or die(mysql_error());
You have a stray )
at the end of your SQL query.
It should be:
mysql_query("UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."'") or die(mysql_error());
Upvotes: 2
Reputation: 146300
Make sure that:
UPDATE customers SET address1='$address1', address2='$address2', city='$city', postcode='$postcode' WHERE username = '".$_SESSION['username']."')
is a real query.
Which you can now see that it isn't because of the extra )
at the end
Upvotes: 3