i created a sign up form in html and have it set to post to php but its not.HELP

So this is driving me insane. usually i can figure stuff like this out by searching the net but no luck so far.
im trying to create a sign up form for a webpage and have it post to a .php the shoot it over to mysql.
as far as i can tell the html works(i may be wrong ) but everytime i try to submit the info from the table it gives me this:

Parse error: syntax error, unexpected ‘"’, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\testfile\PS_Test\signup.php on line 25

i already have my tables set up in mysql i just need to insert the data from the table.

PLEASE HELP, im begging


<form action="signup.php" method=POST>
<table width="300" border="1" align="center" cellpadding="1" cellspacing="1" bgcolor="#000000">
<tr>
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#000000">
<tr>
<td colspan="3"><strong><center>Sign Up<center></strong></td>
</tr>
<tr>
<td width="78">Firstname</td>
<td width="6">:</td>
<td wisth="294"><input name="Firstname" type="text" id="firstname"></td>
</tr>
<tr>
<td width="78">Lastname</td>
<td width="6">:</td>
<td wisth="294"><input name="Lastname" type="text" id="lastname"></td>
</tr>
<td width="78">Age</td>
<td width="6">:</td>
<td wisth="294"><input name="Age" type="text" id="age" </td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

[php]

<?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } else { echo "Connection Successfull"; } $dataselect = mysql_select_db("projectsims_users" ,$con); if(!$dataselect) { die("database not selected".mysql_error()); } $qry=mysql_query("INSERT INTO data_base(Username, Password, FirstName, LastName, Age) VALUES ('$_POST["Username"]','$_POST["Password"]','$_POST["FirstName"]','$_POST["LastName"]','$_POST["Age"]')",$con); if(!$qry) { die("table not created".mysql_error()); } else { echo "values inserted into table successfully"; } ?>[/php]

Easy one… You have to remember that PHP is run on the SERVER-SIDE only. Therefore, you have to keep your PHP outside of your HTML. A query is actually text inside the HTML, it’s not PHP code. Think of it another way as a STRING. A query is a string passed to MySQL.

Your query code slammed it all together.
$qry=mysql_query(“INSERT INTO data_base(Username, Password… Age)
VALUES ‘$_POST[“Username”]’, $_POST[“Password”]’, ‘$_POST[“FirstName”]’,’ …OST[“Age”]’)”,$con);
**** Note the " then ’ then "

The problem is that starting with mysql_query(" you were starting a string. then you put in quotes and mixed in more quotes. This creates a “broken” string which messes up PHP and MySQL. To fix it change it back to a full string…

$qry=mysql_query(“insert into data (name,pass,age)
values (’” . $_POST[“name”] . " ’ , ’ " . $_POST[“pass”] . " ’ , ’ " . $_POST[“age”] . " ’ ) ";
**** note that the PHP code is basically .$_post[] etc… The SQL code inside a string is the value,value,value. You are creating the ‘value’ from a PHP variable which can not be directly inside a string.
You must concat it with '.'s and add in the rest of the SQL with the " ‘,’ "s… Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service