MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2012, 09:52 AM
bakul123 bakul123 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 bakul123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old October 21st, 2012, 10:30 AM
Guelphdad's Avatar
Guelphdad Guelphdad is offline
Hockey face
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Nov 2001
Location: St. Catharines, Canada
Posts: 8,141 Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level)Guelphdad User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 20 h 34 m 13 sec
Reputation Power: 1315
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.

Reply With Quote
  #3  
Old October 21st, 2012, 05:39 PM
Catacaustic's Avatar
Catacaustic Catacaustic is offline
Code Monkey V. 0.9
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2005
Location: A Land Down Under
Posts: 1,898 Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 19 h 1 m 37 sec
Reputation Power: 1798
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.

Reply With Quote
  #4  
Old October 22nd, 2012, 02:05 AM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Dev Shed God 30th Plane (19500 - 19999 posts)
 
Join Date: Jul 2004
Location: USA
Posts: 19,893 Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level) 
Time spent in forums: 6 Months 2 Days 18 h 35 m 4 sec
Reputation Power: 4192
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 ***
__________________
Spreading knowledge, one newbie at a time. I'm available for hire at Dynamic Site Solutions.

Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

Remember people spend most of their time on other people's sites (so don't violate web design conventions).

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > #1064 - You have an error in your SQL syntax; check the manual that corresponds to yo

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap