首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >syntax error, unexpected 'else' (T_ELSE) in /var/www/html/otpprocess.php

syntax error, unexpected 'else' (T_ELSE) in /var/www/html/otpprocess.php
EN

Stack Overflow用户
提问于 2018-06-04 02:00:33
回答 1查看 0关注 0票数 0

下面的代码是验证用户,如果他/她是存在用户它应该登录,如果他/她是新用户,那么它应该插入新的用户在数据库中。同时运行我得到错误

代码语言:javascript
复制
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 error: syntax error, Parse error: syntax error, unexpected 'else' (T_ELSE) in /var/www/html/otpprocess.php on line 25

数据库:

代码语言:javascript
复制
 CREATE TABLE QUOTE (
 phone varchar(),NOT NULL
 PRIMARY KEY(phone)
 ) 
EN

回答 1

Stack Overflow用户

发布于 2018-06-04 11:49:58

代码语言:javascript
复制
echo 'selected';
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100004725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档