Jump to content

why this error in mysql insert query


shwetapandit
Go to solution Solved by MDCode,

Recommended Posts

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

 

<?php
session_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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.