-3

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."') "; "

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.

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

John Conde
  • 217,595
  • 99
  • 455
  • 496
user3032296
  • 33
  • 2
  • 5

2 Answers2

5

You're missing your concatenation operators:

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

It should be

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

PHP should also be warning you about $table_name=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';
Community
  • 1
  • 1
John Conde
  • 217,595
  • 99
  • 455
  • 496
0

Missing dots in concatenating strings around the $table_name:

$sql = "INSERT INTO " . $table_name . "(confirm_code, name, password, email, address, phone, education, date_of_birth) VALUES ...
pavel
  • 26,538
  • 10
  • 45
  • 61