Php 分析错误:语法错误,第107行出现意外的T_变量
下面代码中的第107行是Php 分析错误:语法错误,第107行出现意外的T_变量,php,syntax-error,Php,Syntax Error,下面代码中的第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."') "; "
$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_变量
<?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_变量错误的发生主要是由于错误显示的前一行缺少分号或大括号。但我想我用分号结束了前一行,我没有遗漏任何大括号。但我仍然得到了这个意外的t_变量错误,我不知道为什么会发生。请任何人帮助我解决此问题您缺少连接运算符:
$sql="INSERT INTO " $table_name "(confi
^^^^^ ^^^^^
HERE HERE
应该是
$sql="INSERT INTO " . $table_name . "(confi
PHP还应该警告您关于$table\u name=temp\u members\u db代码>
您的字符串值temp\u members\u db
缺少引号,如果不加引号,该字符串值将被视为/视为
$table_name='temp_members_db';
- 仅供参考,您也对以下内容非常开放
围绕$table\u name
的串接字符串中缺少点:
$sql = "INSERT INTO " . $table_name . "(confirm_code, name, password, email, address, phone, education, date_of_birth) VALUES ...
在$sql=“INSERT-INTO”$table\u-name“
中没有连接$table\u-name
。它应该像$sql=“INSERT-INTO”$table\u-name那样。
没有连接点吗插入“$table\u name”
temp\u members\u db
如果这不是一个常数,那么它需要用引号括起来。看看。这看起来有几个SQL注入漏洞。我还想知道$table\u name=temp\u members\u db代码>-这是否为常数temp_members_db
@Fred ii-这也应该会让PHP感到恼火。它可能会在OP修复连接后很快出现。如果是这样,我们将得到另一个印刷错误问题作为后续!我们现在应该指出这一点。^^(正如我看到你刚才所做的那样哈哈)@johncode我想我们可以把那个绿色的小家伙叫做一个很好的“助手”;-)又一个幸福的结局。