I keep having a syntax error, unexpected $end.

I checked my code, but there's nothing wrong. I checked all the opening and closing brackets. What seems to be the problem?

My code:

<?php
setcookie('name',$_POST['name']);

setcookie('lname',$_POST['lname']);

setcookie('add',$_POST['add']);

setcookie('age',$_POST['age']);

setcookie('contact',$_POST['contact']);

setcookie('email',$_POST['email']);

setcookie('user',$_POST['user']);

setcookie('pass',$_POST['pass']);


$con=mysql_connect("localhost","root","");
mysql_select_db("nnx",$con);

$tbl=mysql_query("SELECT * FROM tablename WHERE `username` =         '".mysql_real_escape_string($_POST['user'])."'");
while($row=mysql_fetch_array($tbl))
{

if($_POST['user']==$row['username'])
{
    header("location: /register.php?codeErr2=1");
        die;
}

$name=$_POST['name'];
$lname=$_POST['lname'];
$add=$_POST['add'];
$age=$_POST['age'];
$contact=$_POST['contact'];
$email=$_POST['email'];
$user=$_POST['user'];
$pass=$_POST['pass'];

if(($name!="")&&($lname!="")&&($add!="")&&($age!="")&&($contact!="")&&($email!="")&&    ($user!="")&&($pass!=""))
{
    $value=mysql_query("INSERT INTO tablename(name, lastname, address, age, contact,     email, username, password)
VALUES     ('".$_POST['name']."','".$_POST['lname']."','".$_POST['add']."','".$_POST['age']."','".$_PO    ST['contact']."','".$_POST['email']."','".$_POST['user']."','".$_POST['pass']."')");
}

else
{
    header("location: /register.php?codeErr=1");    
}


?>

<html>
<body bgcolor="green">
<center>

<h1>Welcome! These are the offered products</h1>
<table border="1" width="1000" height="500" bgcolor="yellow">
<tr>
<th>Product</th>
<th>Description</th>
</tr>
<tr>
<td>GARLIQUE</td>
<td>GARLIQUE
The All Natural Dietary Supplement
Produced from fresh garlic

</td>
</tr>
<tr>
<td>Right-CEE</td>
<td>Right-CEE (Sodium Ascorbate) …

</td>
</tr>
<tr>
<td>OLEIA</td>
<td>OLEIA CAPSULE
No More Pain, Heart to Gain


</td>
</tr>
</table>
<br>
<br>
<form name="product" action="order.php" method="post">
<input type="submit" value="Order">
</form>

</body>
</html>
share|improve this question
1  
The answer is the same as all these stackoverflow.com/… - You have mis-matched brackets. Look at the related column. – Mike B Oct 3 '12 at 14:06
2  
There are so many problems with this code. Please read up on security: docforge.com/wiki/Web_application/Security – Matt S Oct 3 '12 at 14:08
feedback

closed as too localized by Mike B, Vincent Savard, WebnetMobile, Jocelyn, andrewsi Oct 7 '12 at 2:28

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

3 Answers

you forgot to close while:

while($row=mysql_fetch_array($tbl))
{

if($_POST['user']==$row['username'])
{
    header("location: /register.php?codeErr2=1");
        die;
}
}//<---- here
share|improve this answer
hahahahahaha.. im so dumb. Thank you so much :D – Maverick Abella Oct 3 '12 at 14:13
feedback

You're not closing the brace after your while loop.

Indenting your code makes this sort of thing a lot easier to spot!

share|improve this answer
yes i get it now. Thank you. :D – Maverick Abella Oct 3 '12 at 14:15
feedback

You have an opening brace { on the while loop, but you don't seem to have a corresponding closing brace.

share|improve this answer
yes i get it now. Thank you. :D – Maverick Abella Oct 3 '12 at 14:14
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.