在以下代碼中的線107是解析錯誤:語法錯誤,上線意外T_VARIABLE 107
$sql="INSERT INTO " $table_name " (confirm_code,name,password,email,address,phone,education,date_of_birth) VALUES
('".$confirm_code."','".$name."','".$pwd."','".$email."','".$adres."','".$phno."','".$educon."','".$dob."') "; "
我得到意想不到T_VARIABLE;
<?php
if(isset($_POST['Register']))
{
$name= $_POST['uname'];
$pwd= $_POST['pswd'];
$email= $_POST['email'];
$phno= $_POST['phno'];
$adrs= str_replace("'","`",$_POST['adres']);
$adres = $adrs;
$educon= $_POST['educon'];
$dob= $_POST['dob'];
$chkname = "select email from ".USREG." where email='".$email."'";
$res = mysql_query($chkname, $con) or die(mysql_error());
$chkresult=mysql_fetch_array($res);
$uemail= $chkresult['email'];
//print_r($uemail);die();
include ('config.php');
$table_name=temp_members_db;
$confirm_code=md5(uniqid(rand()));
if($uemail==$email)
{
echo ' <p style="color:red">Email <b> '.$email.' </b> Already exists</p>';
}
else
{
$sql="INSERT INTO " $table_name "(confirm_code,name,password,email,address,phone,education,date_of_birth) VALUES
('".$confirm_code."','".$name."','".$pwd."','".$email."','".$adres."','".$phno."','".$educon."','".$dob."') ";
$result = mysql_query($sql, $con) or die(mysql_error());
if($result)
{
$to=$email;
echo '<p style="color:green"> '.$name.' Your Registration Success</p> <br/>';
$subject = "your confirmation link here";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header = 'From: ShareLibrary <'.ADMIN_MAIL.'>' . "\r\n";
$admMesg = $email." is registered ";
$message = "your confrimation link \r\n";
$message = "click on this link to activae your account \r\n";
$message = "http://www.xxxxxx.in/confirmation.php?passkey=$confirm_code";
$sentmail = $mail($to,$subject,$message,$header);
if($sentmail)
{
echo '<p style="color:green">registration details sent to '.$email.' </p><br/>';
}
else
{
echo '<p style="color:red">registration details sending to your mail was failed';
}
}
else
{
echo "<p>Registration FAILED</p>";
}
}
}
?>
上面的代碼是用戶註冊表格,註冊完成後激活碼會去用戶註冊的郵件ID。
我知道T_VARIABLE錯誤的發生主要是由於錯誤顯示之前的行之前缺少分號或大括號。但我認爲我用分號結束了前一行,並且沒有錯過任何大括號。但仍然我得到這個意想不到的t_variable錯誤,我不知道它爲什麼會來。請任何一個幫助我這個怎麼解決這個問題
你不'$ SQL = 「INSERT INTO」 $表名「串聯'$'table_name' ..應該像' $ sql =「INSERT INTO」。$ table_name。「' – Jon
沒有連接點? 'INSERT INTO「$ table_name」' – Rizier123
'temp_members_db'如果它不是一個常量,那麼它需要用引號括起來。 –