-1

我一直有语法错误,意外的 $end。

我检查了我的代码,但没有任何问题。我检查了所有的开始和结束括号。似乎是什么问题?

我的代码:

<?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>
4

3 回答 3

6

你忘了关闭while

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

if($_POST['user']==$row['username'])
{
    header("location: /register.php?codeErr2=1");
        die;
}
}//<---- here
于 2012-10-03T14:05:49.460 回答
3

您没有在while循环后关闭大括号。

缩进你的代码使这种事情更容易被发现!

于 2012-10-03T14:05:56.003 回答
1

{您在循环上有一个左大括号while,但您似乎没有相应的右大括号。

于 2012-10-03T14:06:42.587 回答