The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> MySQL Help
|
#1064 - You have an error in your SQL syntax; check the manual that corresponds to yo
Discuss #1064 - You have an error in your SQL syntax; check the manual that corresponds to yo in the MySQL Help forum on Dev Shed. #1064 - You have an error in your SQL syntax; check the manual that corresponds to yo MySQL Help forum discussing administration, SQL syntax, and other MySQL-related topics. MySQL is an open-source relational database management system (RDBMS).
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 21st, 2012, 09:52 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 1
Time spent in forums: 16 m 53 sec
Reputation Power: 0
|
|
|
#1064 - You have an error in your SQL syntax; check the manual that corresponds to yo
My php process file is
<?php
if (isset($_POST['submit'])) {
$userName = $_POST["username"];
$fullName = $_POST["fullname"];
$email = $_POST["email"];
$password = $_POST["password"];
$con = mysql_connect("localhost", "root", "");
if (!$con) {
die('could not connect:' . mysql_error());
}
mysql_select_db("alhera", $con);
mysql_query("INSERT INTO form('user name', 'full name', 'e-mail', 'password') VALUES('$userName','$fullName','$email','$password ')");
echo "Your record successfully added";
mysql_select_db("alhera", $con);
$result=mysql_query("SELECT*FROM form");
echo"<table border='1'>
<tr>
<th>user name</th>
<th>full name</th>
</tr>";
while($row=mysql_fetch_array($result))
{
echo"<tr>";
echo"<td>" .$row['user name']. "</td>";
echo"<td>" .$row['full name']. "</td>";
echo"</tr>";
}
echo"</table>";
mysql_close($con);
}
?>
And
Local host table is
1 user name varchar(15) latin1_swedish_ci No None Change Drop More
2 full name varchar(15) latin1_swedish_ci No None Change Drop More
3 e-mail varchar(25) latin1_swedish_ci No None Change Drop More
4 password varchar(15) latin1_swedish_ci No None Change Drop more
Please Help me to solution
|

October 21st, 2012, 10:30 AM
|
 |
Hockey face
|
|
Join Date: Nov 2001
Location: St. Catharines, Canada
|
|
|
First step, when asking for mysql help, get rid of all of the rest of the php code and just show us the relevant part.
Second when you enclose a column name in single quotes mysql recognizes it as a string and not a column name. Remove those around the column names.
Third don't use spaces in column names.
when you've cleaned second and third points up you should be fine.
|

October 21st, 2012, 05:39 PM
|
 |
Code Monkey V. 0.9
|
|
Join Date: Mar 2005
Location: A Land Down Under
|
|
This is a PHP question, not a HTML question (one of the mods might want to move this).
Your query is wrong. It's a pretty basic SQL syntax problem. When you use database, table or column names in a query, you use back-ticks (`) round them, not quotes ('). So, your query would need to be something like:
PHP Code:
mysql_query("INSERT INTO form(`user name`, `full name`, `e-mail`, `password`) VALUES('$userName','$fullName','$email','$password ')");
One other thing that's a recommendation: your column names are going to cause you problems somewhere down the line. As a general rule, you should not use spaces, dashes or special characters. Stick to letters, numbers and underscores only as these are a lot easier to work with and will ensure no issues later on.
|

October 22nd, 2012, 02:05 AM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
Welcome to DevShed Forums, bakul123.
Please don't post the same question in multiple forums. Pick the one that you feel is best. (If it turns out another is better, a moderator can move your thread for you.) ( Cross-post in MySQL forum.)
P.S. It would be helpful if you put your code between [code][/code] tags in the future.
*** Thread Moved to MySQL Forum ***
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|