语法错误,/var/www/html/otpprocess.php中的意外'else'(T_ELSE)

时间:2018-05-31 09:08:43

标签: php mysqli

以下代码用于验证用户是否存在用户应该登录的用户,如果他/她是新用户,则应将新用户插入数据库。 在运行时遇到错误

code:
<?php
session_start();
$url='127.0.0.1';
$username = "root";
$password = "";
$dbname = "db";
$conn = mysqli_connect($url, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$rno=$_SESSION['otp'];
$urno=$_POST['otpvalue'];
if(!strcmp($rno,$urno))
{
// check the existance user
$phone=$_SESSION['phone'];
//select the user from database
$sql_e = "SELECT * FROM quote WHERE '$phone'";

$res_e = mysqli_query($conn,$sql_e);
echo 'selected';
if(mysqli_num_rows($conn,$res_e) > 0){
  $phone_error = "Sorry... email already taken";    
}
else{

   // Create connection
       $sql = "INSERT INTO quote (phone) VALUES ('$phone')";
       $results = mysqli_query($conn,$sql);
       echo 'Saved!';

     if (mysqli_query($conn, $sql)){


  $mobileNumber = $phone;
 //Sender ID,While using route4 sender id should be 6 characters long.
 $senderId = "ABCDEF";
 //Your message to send, Add URL encoding here.
 $message = urlencode("Thank u for register with us. we will get back to u
 shortly.");    
//Define route
$route = "route=4";
 //Prepare you post parameters
 $postData = array(

 'mobiles' => $mobileNumber,
 'message' => $message,
 'sender' => $senderId,
 'route' => $route
  );
  //API URL
  $url="https://2factor.in/API/V1/7d4dac17-dd42-11e5-9a14-00163ef91450
   /SMS/$mobileNumber/$rndno/ADDIEE";
  // init the resource
  $ch = curl_init();
  curl_setopt_array($ch, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => $postData
  //,CURLOPT_FOLLOWLOCATION => true
  ));
  //Ignore SSL certificate verification
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  //get response
   $output = curl_exec($ch);
    //Print error if any


   if(curl_errno($ch))
  {
 echo 'error:' . curl_error($ch);
 }
 curl_close($ch);
 header( "Location: upload_index.php" );
  } 

 else {
 echo "Error: " . $sql . "<br>" . mysqli_error($conn);
 }
  mysqli_close($conn);
  return true;
  }
  }
 else
 {
  echo "<script type='text/javascript'>alert('failed!')</script>";
 //echo "failure";
 return false;
 }
  ?> 

如果我尝试上面的代码显示错误,则错误是Parse错误:语法错误,解析错误:语法错误,第25行/var/www/html/otpprocess.php中的意外'else'(T_ELSE)< / p>

数据库:

 CREATE TABLE QUOTE (
 phone varchar(),NOT NULL
 PRIMARY KEY(phone)
 ) 

1 个答案:

答案 0 :(得分:0)

echo 'selected';

你错过了分号