解析错误:语法错误,第 107 行出现意外的 T_VARIABLE [英] Parse error: syntax error, unexpected T_VARIABLE on line 107

查看:28
本文介绍了解析错误:语法错误,第 107 行出现意外的 T_VARIABLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面代码中的第 107 行是

The line 107 in the below code is

$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;

i am getting unexpected 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>";
            }
        } 
    } 
?>

以上代码为用户注册表格,注册完成后激活码会发送到用户注册的邮箱中.

the above code is for user registration form after registration completes the activation code will go to users registered mail id.

我知道 T_VARIABLE 错误的发生主要是由于缺少显示错误的前一行中的分号或大括号.但我想我用分号结束了前一行,我没有错过任何大括号.但我仍然收到这个意外的 t_variable 错误,我不知道它为什么会出现.请任何人帮我解决这个问题

i knew that T_VARIABLE error will occurs mostly due to missing semicolon or braces from the before line where the error is showing. but i think i ended the before line with semicolon and i did't miss any braces. but still i am getting this unexpected t_variable error i dont know why it is coming. please any one help me with this how to solve this problem

推荐答案

您缺少连接运算符:

 $sql="INSERT INTO " $table_name      "(confi
                   ^^^^^         ^^^^^
                   HERE          HERE

应该是

$sql="INSERT INTO " . $table_name . "(confi

PHP 还应该警告您关于 $table_name=temp_members_db;.

PHP should also be warning you about $table_name=temp_members_db;.

您在字符串值 temp_members_db 周围缺少引号,它被视为/处理为 常量(如果没有引用).

You're missing quotes around your string value temp_members_db which is considered/treated as a constant if not quoted.

$table_name='temp_members_db';

  • 仅供参考,您也对SQL 注入持开放态度.
  • 这篇关于解析错误:语法错误,第 107 行出现意外的 T_VARIABLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆