Results 1 to 6 of 6
-
14th Sep 2011, 06:11 AM #1OP
what's worng this code ? help
hi all friends
i code in php for a multipage registration form like
first page :first name, last name
2nd pagearental details
.
.
last will submit all data to mysql database
the code is here by page but after last page that will submit data to database got a problem.
the problem isCode: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 '='shalah', email_addres= 'uddin', membership_' at line 2
page1:
PHP Code:<form method="post" action="page2.php">
First Name:<input type="text" name="first_name" /><br>
Last Name:<input type="text" name="last_name" /><br>
<input type="submit" name="submit" />
</form>
PHP Code:<?php
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
?>
<html>
<head></head>
<body>
<form method="post" action="page3.php">
<input type="hidden" name="first_name" value="<?php echo $fname;?>" />
<input type="hidden" name="last_name" value="<?php echo $lname;?>" />
Education:<input type="text" name="education" /><br>
School:<input type="text" name="school" /><br>
<input type="submit" name="submit" />
</form>
</body>
</html>
PHP Code:<?php
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
$education=$_POST['education'];
$school=$_POST['school'];
?>
<html>
<head></head>
<body>
<form method="post" action="page4.php">
<input type="hidden" name="first_name" value="<?php echo $fname;?>" />
<input type="hidden" name="last_name" value="<?php echo $lname;?>" />
<input type="hidden" name="education" value="<?php echo $education;?>" />
<input type="hidden" name="school" value="<?php echo $school;?>" />
Experience:<input type="text" name="experience" /><br>
<input type="submit" name="submit" />
</form>
</body>
</html>
PHP Code:<?php
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
$education=$_POST['education'];
$school=$_POST['school'];
$expe=$_POST['experiance'];
//let's create the query
$insert_query = "insert into subscriptions (
name='$fname',
email_addres= '$lname',
membership_type= '$education',
terms_and_conditions='$school',
name_on_card='$expe')";
//let's run the query
$connect=mysql_connect("localhost","root","");
if(!$connect)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("reg",$connect);
if (!mysql_query($insert_query,$connect))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
thanks in advanceshakac Reviewed by shakac on . what's worng this code ? help hi all friends i code in php for a multipage registration form like first page :first name, last name 2nd page:parental details . . last will submit all data to mysql database the code is here by page but after last page that will submit data to database got a problem. the problem is 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 '='shalah', email_addres= 'uddin', Rating: 5
-
14th Sep 2011, 02:22 PM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inThe problem is with your mysql query syntax
PHP Code:$insert_query = "insert into subscriptions (
name='$fname',
email_addres= '$lname',
membership_type= '$education',
terms_and_conditions='$school',
name_on_card='$expe')";
PHP Code:$insert_query = "INSERT INTO subscriptions (name, email_addres, membership_type, terms_and_conditions, name_on_card)
VALUES ($fname, $lname, $education, $school, $expe) ";
Just replace page3 with this:
PHP Code:<?php
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
$education=$_POST['education'];
$school=$_POST['school'];
$expe=$_POST['experiance'];
//let's create the query
$insert_query = "INSERT INTO subscriptions (name, email_addres, membership_type, terms_and_conditions, name_on_card)
VALUES ($fname, $lname, $education, $school, $expe) ";
//let's run the query
$connect=mysql_connect("localhost","root","");
if(!$connect)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("reg",$connect);
if (!mysql_query($insert_query,$connect))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
-
14th Sep 2011, 02:25 PM #3MemberWebsite's:
premium-links.net wanted-programs.comdepending on ur Table data type add those....
PHP Code:$insert_query = "INSERT INTO subscriptions(name, email_addres, membership_type, terms_and_conditions, name_on_card) VALUES ('$fname', '$lname', '$education', '$school', '$expe')";
-
14th Sep 2011, 02:51 PM #4Member
if the strings come from user input, you should escape them before putting it into queries... http://www.tizag.com/mysqlTutorial/m...-injection.php
-
14th Sep 2011, 02:52 PM #5MemberWebsite's:
premium-links.net wanted-programs.com
-
17th Sep 2011, 08:18 PM #6Member
i think the first one reply its correct
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Help With Letitbit Js To BB Code aka Embedding streaming code in forums
By JoomlaZ in forum Web Development AreaReplies: 1Last Post: 3rd Apr 2012, 09:50 AM -
Looking for a code fix
By Divvy in forum Web Application/Script SupportReplies: 1Last Post: 15th Dec 2011, 05:51 PM -
Need a good coder to code a skin, I will show you what I need, you just code it
By Nickk96 in forum Web Development AreaReplies: 1Last Post: 27th Aug 2011, 01:45 PM -
code [url] BB-code ?
By Emperor in forum vBulletinReplies: 3Last Post: 16th Sep 2010, 10:55 PM -
[vBulletin BB Code] Moderated Message: (Like W-BB's Staff BB Code!)
By Ghost Dog 13 in forum Webmaster ResourcesReplies: 13Last Post: 26th Sep 2009, 06:19 PM
themaCreator - create posts from...
Version 3.53 released. Open older version (or...