解析错误php MySQL查询出现问题

时间:2019-05-07 17:00:27

标签: php html mysql

所以我要查询“ SELECT * FROM Accounts where where Email ='$ email'”

这是在if(isset(submit))语句中

每当我尝试加载页面时,都会出现Parse错误:语法错误,/home/vol7_2/epizy.com/epiz_23758113/htdocs/registeraccount.php中第157行上的意外“帐户”(T_STRING)

我已经上下搜索了,每个示例似乎都显示了这种查询方式。

任何***都是我已删除的敏感信息。

这是我的代码。

<?php
session_start( );
require_once(__DIR__ . '/square-connect/autoload.php');

 // Configure OAuth2 access token for authorization: oauth2
$accesstoken = '***ACCESSTOKENVALUE***';
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken($accesstoken);
//configure sql
$link = new mysqli("localhost", "epiz_23758113", "***password***", "epiz_23758113_Customers");
//setting vars from form on submit
if(isset($_REQUEST['submit']))
{
//check passwords match
if($_POST["contact_form_pass1"] != $_POST["contact_form_pass2"]){
    if (empty($formerrormsg)){
        $formerrormsg = "Passwords Do Not MATCH";
    } else {
        $formerrormsg = $formerrormsg . "<br/> Passwords Do Not MATCH";
    }
        //check password meets critera
        if(!preg_match('/^[a-z0-9_-]{6,18}$/', $_POST["contact_form_pass1"])){
            if (empty($formerrormsg)){
                $formerrormsg = "Password must be 6-18 Characters and must only be letters, number, - or _";
            } else {
                $formerrormsg = $formerrormsg . "<br/> Password must be 6-18 Characters and must only be letters, number, - or _";
            }
            //Check Email is Valid
            if(!preg_match('/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/', $_POST["contact_form_email"])){
                if (empty($formerrormsg)){
                    $formerrormsg = "Email must be valid ie. you@you.com";
                } else {
                    $formerrormsg = $formerrormsg . "<br/> Email must be valid ie. you@you.com";
                }
                if(!preg_match('/^[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}(\-| |){1}[0-9]{1}[a-zA-Z]{1}[0-9]{1}$/', $_POST["contact_form_PostalCode"])){
                    if (empty($formerrormsg)){
                        $formerrormsg = "postal code must be valid ie. A1A-1A1";
                    } else {
                        $formerrormsg = $formerrormsg . "<br/> postal code must be valid ie. A1A-1A1";
                    }
                    if(empty($_POST["contact_form_first-name"])) {
                        if (empty($formerrormsg)){
                            $formerrormsg = "You need to enter a first name";
                        } else {
                            $formerrormsg = $formerrormsg . "You need to enter a first name";
                        }
                        if(empty($_POST["contact_form_last-name"])) {
                            if (empty($formerrormsg)){
                                $formerrormsg = "You need to enter a last name";
                            } else {
                                $formerrormsg = $formerrormsg . "<br/> You need to enter a last name";
                            }
                            if(empty($_POST["contact_form_phone"])) {
                                if (empty($formerrormsg)){
                                    $formerrormsg = "You need to enter a phone number";
                                } else {
                                    $formerrormsg = $formerrormsg . "<br/> You need to enter a phone number";
                                }
                                if(empty($_POST["contact_form_email"])) {
                                    if (empty($formerrormsg)){
                                        $formerrormsg = "You need to enter an email address";
                                    } else {
                                        $formerrormsg = $formerrormsg . "<br/> You need to enter an email address";
                                    }
                                    if(empty($_POST["contact_form_pass1"])) {
                                        if (empty($formerrormsg)){
                                            $formerrormsg = "You need to enter a password";
                                        } else {
                                            $formerrormsg = $formerrormsg . "<br/> You need to enter a password";
                                        }
                                        if(empty($_POST["contact_form_pass2"])) {
                                            if (empty($formerrormsg)){
                                                $formerrormsg = "You need to verify your password";
                                            } else {
                                                $formerrormsg = $formerrormsg . "<br/> You need to verify your password";
                                            }
                                            if(empty($_POST["contact_form_st-address"])) {
                                                if (empty($formerrormsg)){
                                                    $formerrormsg = "You need to enter an address";
                                                } else {
                                                    $formerrormsg = $formerrormsg . "<br/> You need to enter an address";
                                                }
                                                if(empty($_POST["contact_form_province"])) {
                                                    if (empty($formerrormsg)){
                                                        $formerrormsg = "You need to chose a province";
                                                    } else {
                                                        $formerrormsg = $formerrormsg . "<br/> You need to chose a province";
                                                    }
                                                    if(empty($_POST["contact_form_PostalCode"])) {
                                                        if (empty($formerrormsg)){
                                                            $formerrormsg = "You need to enter a postal code";
                                                        } else {
                                                            $formerrormsg = $formerrormsg . "<br/> You need to enter a postal code";
                                                        }
                                                        if(empty($_POST["contact_form_city"])) {
                                                            if (empty($formerrormsg)){
                                                                $formerrormsg = "You need to enter a city";
                                                            } else {
                                                                $formerrormsg = $formerrormsg . "<br/> You need to enter a city";
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
else if(isset($_REQUEST['submit']))
{
    if(is_null($check)){
        $first_name = mysql_real_escape_string($_POST['contact_form_first-name']);
        $last_name = mysql_real_escape_string($_POST['contact_form_last-name']);
        $phone = mysql_real_escape_string($_POST['contact_form_phone']);
        $email = mysql_real_escape_string($_POST['contact_form_email']);
        $pass1 = mysql_real_escape_string($_POST['contact_form_pass1']);
        $street = mysql_real_escape_string($_POST['contact_form_st-address']);
        $stdir = mysql_real_escape_string($_POST['contact_form_st-dir']);
        $address = $street . " " . $stdir;
        $apt = mysql_real_escape_string($_POST['contact_form_apt']);
        $province = mysql_real_escape_string($_POST['contact_form_province']);
        $postalcode = mysql_real_escape_string($_POST['contact_form_PostalCode']);
        $city = mysql_real_escape_string($_POST['contact_form_city']);
        $verified = 0;
        $password = password_hash($pass1);

        $country = "CA";
        $body = new \SquareConnect\Model\CreateCustomerRequest();
        $body->setGivenName($first_name);                                                   
        $body->setFamilyName($last_name);                                                   
        $body->setEmailAddress($email);                                                    
        $body->setPhoneNumber($phone);                                                     
        $body->setAddress()->setAddressLine1($address);                                    
        $body->setAddress()->setAddressLine2($apt);                                        
        $body->setAddress()->setLocality($city);                                           
        $body->setAddress()->setAdministrativeDistrictLevel1($province);                   
        $body->setAddress()->setPostalCode($postalcode);                                   
        $body->setAddress()->setCountry($country);     
        try {
            $customerresult = $customers_api->createCustomer($body);
            $customer_id = $customerresult->getCustomer()->getId();
            $customersession = array
            (
                'id'=>$customer_id,
                'firstname'=>$firstname,
                'lastname'=>$lastname,
                'pass'=>$password
            );
            $_SESSION["Customer"] = $customersession;
            //ADD TO DB
            $sql = “SELECT * FROM Accounts WHERE Email =‘“.$email.”’”;
            $result = mysqli_query($con,$sql);
            $num_rows = mysql_fetch_array($result);
            if ($num_rows > 0) {
               //ALREADY EXISTS IN DB SO UPDATE IT
                if (empty($formerrormsg)){
                    $formerrormsg = "YOUR EMAIL IS ALREADY REGISTERED!";
                } else {
                    $formerrormsg = $formerrormsg . "<br/> YOUR EMAIL IS ALREADY REGISTERED!";
                }
            } else {
              //DOES NOT EXIST IN DB SO INSERT IT
              $result = $link->query("INSERT IGNORE INTO Customers('CustomerId,FirstName,LastName,Email,password,Phone,Address,Apt,City,Province,PostalCode,Country,verified') VALUES ('$customer_id,$first_name,$last_name,$email,$password,$phone,$address,$apt,$city,$province,$postalcode,$country,$verified')");
                if ($result === false) {
                    if (empty($formerrormsg)){
                        $formerrormsg = "SQL error:".$mysqli->error;
                    } else {
                        $formerrormsg = $formerrormsg . "<br/> SQL error:".$mysqli->error;
                    }
                }
                header('Location: http://www.phoneloft.ca/login.php?register=yes');
                exit;
            }
        } catch (Exception $e) {
            if (empty($formerrormsg)){
                $formerrormsg = "Exception when calling CustomersApi->createCustomer: ", $e->getMessage(), PHP_EOL;
            } else {
                $formerrormsg = $formerrormsg . "Exception when calling CustomersApi->createCustomer: ", $e->getMessage(), PHP_EOL;
            }
        } 
    }
}
} 
Exit();                         
?>

0 个答案:

没有答案