以下代码中的第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错误我不知道它为什么会来。请任何人帮我解决这个问题
答案 0 :(得分:5)
你错过了连接操作符:
$sql="INSERT INTO " $table_name "(confi
^^^^^ ^^^^^
HERE HERE
应该是
$sql="INSERT INTO " . $table_name . "(confi
PHP也应该警告你$table_name=temp_members_db;
。
您的字符串值temp_members_db
周围缺少引号,如果没有引用,则会被视为/视为constant。
$table_name='temp_members_db';
答案 1 :(得分:0)
在$table_name
:
$sql = "INSERT INTO " . $table_name . "(confirm_code, name, password, email, address, phone, education, date_of_birth) VALUES ...