如何解决Parse错误:语法错误,意外'TABLE_PLEDGES'(T_STRING)

时间:2016-01-20 13:20:45

标签: php android sql database syntax-error

我正在将我的SQL数据库连接到Android应用程序。我已经创建并连接了数据库,所以我现在正在尝试连接这个php文件。我得到了这个 - 解析错误:语法错误,第13行意外的'TABLE_PLEDGES'(T_STRING)

$name = $_GET[‘name’];
$emailAddress = $_GET[‘emailAddress’];
$phoneNumber = $_GET[‘phoneNumber’];
$amount = $_GET[‘amount’];
$date = $_GET[‘date’];

if($name == ‘’ || $emailAddress == ‘’ || $phoneNumber == ‘’ || $amount == ‘’ || $date == “”){
    echo ‘yes’;
}else{
    _once(‘dbConnect.php’);
    $sql = “SELECT * FROM TABLE_PLEDGES WHERE name=‘$name’ OR emailAddress=‘$emailAddress’”;

    $check = mysqli_fetch_array(mysqli_($con,$sql));

    if(isset($check)){
        echo ‘name or email already exist’;
    }else{
        $sql = “INSERT INTO TABLE_PLEDGES (name,emailAddress,phoneNumber,amount, date) VALUES(‘$name’,’$emailAddress’,’$phoneNumber’,’$amount’,’$date’)”;
    if(mysqli_($con,$sql)){
        echo ‘pledge accepted’;
    }else{
        echo ‘oops! Please try again!’;
    }
}
mysqli_close($con);
}

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:2)

而不是使用你使用回溯的引号。使用引号,你的问题就会消失

<?php
$name = $_GET["name"];
$emailAddress = $_GET["emailAddress"];
$phoneNumber = $_GET["phoneNumber"];
$amount = $_GET["amount"];
$date = $_GET["date"];

if($name == "" || $emailAddress == "" || $phoneNumber == "" || $amount == "" || $date == ""){
    echo "yes";
}else{
    require_once("dbConnect.php"); //instead of _once it will be require_once
    $sql = "SELECT * FROM TABLE_PLEDGES WHERE name="$name" OR emailAddress="$emailAddress"";

    $check = mysqli_fetch_array(mysqli_($con,$sql));

    if(isset($check)){
        echo "name or email already exist";
    }else{
        $sql = "INSERT INTO TABLE_PLEDGES (name,emailAddress,phoneNumber,amount, date) VALUES("$name","$emailAddress","$phoneNumber","$amount","$date")";
    if(mysqli_query($con,$sql)){ // instead of mysqli_ it will be mysqli_query
        echo "pledge accepted";
    }else{
        echo "oops! Please try again!";
    }
}
mysqli_close($con);
}