NickG21 Posted August 10, 2009 Share Posted August 10, 2009 Hey Everyone, Could someone tell me if im getting this error because of a syntax error or possibly because there is an empty variable? And if an empty variable could someone tell me how to error check for this now and in the future? thanks in advance for any help Nick Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/alloutd1/public_html/test/YourLife/checkout2.php on line 20 <?php include("header.inc.php"); $CuID = $_COOKIE['PHPSESSID']; /*Get Customer Info*/ $SQLUser = "SELECT * from tblCustomer Where CuBillAddress ='" . $_GET['addr'] . "' AND CuEmail='" . $_GET['email'] . "'"; $rsSQLUser = mysql_query($SQLUser); $CuInfo = mysql_fetch_array($rsSQLUser); /*Get Products from Cart*/ $SQLCuCart = "SELECT CartPrID, CartPrQty from tblCart Where CartSessionID ='" . $_GET['id'] . "'"; $rsSQLCuCart = mysql_query($SQLCuCart); if(isset($_POST['order'])){ /*Get Customer Info*/ $SQLUser = "SELECT * from tblCustomer Where CuBillAddress ='" . $_GET['addr'] . "' AND CuEmail='" . $_GET['email'] . "'"; $rsSQLUser = mysql_query($SQLUser); $CuInfo = mysql_fetch_array($rsSQLUser); /*Get Products from Cart*/ $SQLCuCart = "SELECT CartPrID, CartPrQty from tblCart Where CartSessionID ='" . $_GET['id'] . "'"; $rsSQLCuCart = mysql_query($SQLCuCart); /*Log order before individual products*/ Line 20: $SQLOrder = "INSERT into tblOrder (OrID, OrDate, OrCuShipFName,OrCuShipLName,OrCuShipAddress,OrCuShipCity,OrCuShipState,OrCuShipZip,OrCuShipEmail,OrCuShipPhone,OrCuBillFName,OrCuBillLName,OrCuBillAddress,OrCuBillCity,OrCuBillState,OrCuBillZip,OrCuBillEmail,OrItemTotal,OrShippingTotal,OrAuthorization,OrStatus) values('',now(),'$CuInfo['CuShipFName'],$CuInfo['CuShipLName']','$CuInfo['CuShipAddress']','$CuInfo['CuShipCity']','$CuInfo['CuShipState']','$CuInfo['OrCuShipZip']','$CuInfo['OrCuShipEmail']','$CuInfo['CuShipPhone']','$CuInfo['OrCuBillFName']','$CuInfo['OrCuBillLName']','$CuInfo['OrCuBillAddress']','$CuInfo['OrCuBillCity']','$CuInfo['OrCuBillState']','$CuInfo['OrCuBillZip']','$CuInfo['OrCuBillEmail']','$_SESSION['total']','','','')"; echo $SQLOrder; /*Log individual products*/ while($row = mysql_fetch_array($rsSQLCuCart)){ $SQLPrInfo = "SELECT * from tblProduct where PrID='" . $row['CartPrID'] . "'"; $rsSQLPrInfo = mysql_query($SQLPrInfo); $PrInfo = mysql_fetch_array($rsSQLPrInfo); echo $PrInfo['PrID'] . "<br/>"; /*$SQLCuOrder = "INSERT into tblOrderProduct(OpID, OpOrID, OrCartPrID, OpCartPrQty, OpPrPrice, OpPrMaker) values('$row['CartPrID']',' */ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169680-solved-parse-error-syntax-error-unexpected-t_encapsed_and_whitespace-error/ Share on other sites More sharing options...
sasa Posted August 11, 2009 Share Posted August 11, 2009 change line 20 to $SQLOrder = "INSERT into tblOrder (OrID, OrDate, OrCuShipFName,OrCuShipLName,OrCuShipAddress,OrCuShipCity,OrCuShipState,OrCuShipZip,OrCuShipEmail,OrCuShipPhone,OrCuBillFName,OrCuBillLName,OrCuBillAddress,OrCuBillCity,OrCuBillState,OrCuBillZip,OrCuBillEmail,OrItemTotal,OrShippingTotal,OrAuthorization,OrStatus) values('',now(),'$CuInfo[CuShipFName],$CuInfo[CuShipLName]','$CuInfo[CuShipAddress]','$CuInfo[CuShipCity]','$CuInfo[CuShipState]','$CuInfo[OrCuShipZip]','$CuInfo[OrCuShipEmail]','$CuInfo[CuShipPhone]','$CuInfo[OrCuBillFName]','$CuInfo[OrCuBillLName]','$CuInfo[OrCuBillAddress]','$CuInfo[OrCuBillCity]','$CuInfo[OrCuBillState]','$CuInfo[OrCuBillZip]','$CuInfo[OrCuBillEmail]','$_SESSION[total]','','','')"; Quote Link to comment https://forums.phpfreaks.com/topic/169680-solved-parse-error-syntax-error-unexpected-t_encapsed_and_whitespace-error/#findComment-895294 Share on other sites More sharing options...
NickG21 Posted August 11, 2009 Author Share Posted August 11, 2009 hey Sasa, when I use that syntax for the Insert statement, all of the field values are blank except for my Session variable, and the statement does not execute properly anyway. When I plug in the Insert statement, even with the blank values, into a query window in PHPMyAdmin, I receive this error; SQL query: NSERT INTO tblOrder( OrID, OrDate, OrCuShipFName, OrCuShipLName, OrCuShipAddress, OrCuShipCity, OrCuShipState, OrCuShipZip, OrCuShipEmail, OrCuShipPhone, OrCuBillFName, OrCuBillLName, OrCuBillAddress, OrCuBillCity, OrCuBillState, OrCuBillZip, OrCuBillEmail, OrItemTotal, OrShippingTotal, OrAuthorization, OrStatus ) VALUES ( '', now( ) , ',', '', '', '', '', '', '', '', '', '', '', '', '', '', '1499.5', '', '', '' ) MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NSERT into tblOrder (OrID, OrDate, OrCuShipFName,OrCuShipLName,OrCuShipAddress,O' at line 1 any ideas about this? thanks again Quote Link to comment https://forums.phpfreaks.com/topic/169680-solved-parse-error-syntax-error-unexpected-t_encapsed_and_whitespace-error/#findComment-895612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.