PHP错误:致命错误:未捕获PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法中有错误;

时间:2018-05-01 15:54:49

标签: php mysql post

我正在尝试为我的网站编写注册脚本。所有这个脚本都是从页面获取用户输入,并将其发送到MySQL。我正在使用PDO,因为它应该更安全,但我找不到语法错误。

signup3.inc.php

<?php
// create a db connection

//initializing variables <br/><br/>
$FirstName = "";<br/>
$LastName = "";<br/>
$userName = "";<br/>
$userEmail = "";<br/>
$cUserEmail = "";<br/>
$password = "";<br/>
$cPassword = "";<br/>
$userAddress = "";<br/>
$userAddress2 = "";<br/>
$userZip = "";<br/>
$userCity = "";<br/>
$userState = "";<br/>
$userPhone = "";<br/>
$userID = "";<br/>
$today = date("r");<br/>

//defining variables

if(isset($_POST['FirstName'])){$FirstName = $_POST['FirstName'];}; <br/>
if(isset($_POST['LastName'])){$LastName= $_POST['LastName'];};<br/>
if(isset($_POST['userName'])){$userName = $_POST['userName'];};<br/>
if(isset($_POST['userEmail'])){$UserEmail =  $_POST['userEmail'];};<br/>
if(isset($_POST['cUserEmail'])){$cUserEmail =  $_POST['cUserEmail'];};<br/>
if(isset($_POST['password'])){$password = $_POST['password'];};<br/>
if(isset($_POST['cPassword'])){$cPassword = $_POST['cPassword'];};<br/>
if(isset($_POST['userAddress'])){$userAddress =  $_POST['userAddress'];};<br/>
if(isset($_POST['userAddress2'])){$userAddress2 =  $_POST['userAddress2'];};<br/>
if(isset($_POST['userZip'])){$userZip =  $_POST['userZip'];};<br/>
if(isset($_POST['userCity'])){$userCity =  $_POST['userCity'];};<br/>
if(isset($_POST['userState'])){$userState = $_POST['userState'];};<br/>
if(isset($_POST['userPhone'])){$userPhone =  $_POST['userPhone'];};<br/>

$query = "INSERT INTO userprofile (userFirstName, userLastName, userCity, userState, userZip, userRegDate, userPhone, userAddress, userAddress2, userEmail, userName) <br/>
VALUES ($FirstName,$LastName,$userCity,$userState,$userZip,$today,$userPhone,$userAddress,$userAddress2,$userEmail,$userName)";


$connect->exec($query);

echo "<script> alert('Account successfully created!'); window.location='index.html'</script>";

0 个答案:

没有答案