shwetapandit Posted November 17, 2013 Share Posted November 17, 2013 this is my html file.when i am submitting the file it shows : 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 'set) VALUES ('', '11','11' ,'nashik' ,'mh' ,'india', '1' )' at line 1 why it is so.any suggestions........ add_address.html <html> <head> <title>Add Address</title> </head> <body> <table border="1" cellspacing="2" cellpadding="0"> <tr><td> <h2>Add Address here</h2></td></tr> <form action="add_address.php" method="POST"><tr><td> Add1:<input type="text" name="add1" id="add1"><br/></td></tr><tr><td> Add2:<input type="text" name="add2" id="add2"><br/> </td></tr><tr><td> City:<input type="text" name="city" id="city"><br/></td></tr><tr><td> State:<input type="text" name="state" id="state"><br/></td></tr><tr><td> Country:<input type="text" name="country" id="country"><br/></td></tr><tr><td><h2>would you like to make it default address</h2></td></tr><tr><td>Yes:<input type="radio" name="set" value="1" id="set"><br/></td></tr><tr><td> No:<input type="radio" name="set" value="0" id="set"><br/></td></tr><tr><td> <input type="submit" name="submit" value="submit"><br/></td></tr> </form> </body></html> add_address.php <?phpsession_start();if(isset($_POST['submit'])){if (isset($_SESSION['email'])) {$uid=$_SESSION['uid'];$con=mysql_connect("localhost","root","")or die(mysql_error());mysql_select_db("regis")or die(mysql_error());$add1=$_POST['add1'];$add2=$_POST['add2'];$city=$_POST['city'];$state=$_POST['state'];$country=$_POST['country'];if (isset($_POST['set'])){$set=$_POST['set'];}mysql_query("INSERT INTO address (uid, add1, add2, city, state, country, set)VALUES ('$uid', '$add1','$add2' ,'$city' ,'$state' ,'$country', '$set' )")or die(mysql_error());echo "Your address get saved in our Database";echo "<br/>";}}?><a href="logout.php">logout</a><br/><a href="add_address.php">Would you like to add another address</a><br/><a href="default.html">Next Page</a> Link to comment https://forums.phpfreaks.com/topic/283989-why-this-error-in-mysql-insert-query/ Share on other sites More sharing options...
MDCode Posted November 17, 2013 Share Posted November 17, 2013 Set is a MySQL reserved name. Surround it with backticks. In case of confusion, the column name. Not the variable. Link to comment https://forums.phpfreaks.com/topic/283989-why-this-error-in-mysql-insert-query/#findComment-1458653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.