NickG21 Posted July 22, 2009 Share Posted July 22, 2009 Hey guys, i keep receiving this parse error of: Parse error: syntax error, unexpected '"' in /.../order.php on line 13 Line 13 is as follows: /*Get Products from Cart*/ Line 13: $SQLCuCart = "SELECT CartPrID, CartPrQty from tblCart Where CartSessionID = '" . $_COOKIE["PHPSESSID"] . "'"; $rsSQLCuCart = mysql_query($SQLCuCart); echo $SQLCuCart; The real issue im having is that im using the exact same query on the page before which is a type of "Order Overview" page and everything is working perfectly. I have been using this same method of querying throughout this project and it has worked fine the entire way until i made this order.php page. Any insight would be excellent, thank you, NickG Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/ Share on other sites More sharing options...
ignace Posted July 22, 2009 Share Posted July 22, 2009 Post the entire code please as that would work fine. Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-880590 Share on other sites More sharing options...
NickG21 Posted July 23, 2009 Author Share Posted July 23, 2009 Here's the entire page; <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); include("header.inc.php"); foreach ($_POST as $key => $value) { $$key = $value; echo $$key; } /*Update tblCustomer with CC Information*/ $sqlCCUpdate = "UPDATE tblCustomer set CuCCType = '" . $CCardType . "', CuCCNum = '" . $CCNum . "', CuCCSVC = '" . $CCCSV . "', CCExpDate= '" . $CCYear . "',CCName='" . $CCName . '" WHERE CuSessID = "' . $_COOKIE['PHPSESSID'] . '"; echo $sqlCCUpdate; $rssqlCCUpdate = mysql_query($sqlCCUpdate); /*Get Products from Cart*/ Line 17 Error Line: $SQLCuCart = "SELECT CartPrID, CartPrQty from tblCart Where CartSessionID = '" . $_COOKIE['PHPSESSID'] . "'"; $rsSQLCuCart = mysql_query($SQLCuCart) or die("Query Unsuccesful using CartSessION"); echo $SQLCuCart; ?> <div id="content"> <table> <?php while($PrIDs = mysql_fetch_array($rsSQLCuCart)){ $PrID = $PrIDs['CartPrID']; $ProdSQL = "SELECT PrName,PrImage,PrPrice from tblProduct where PrID ='$PrID'"; $rsProdSQL = mysql_query($sql) or die("No PrID associated"); while($row = mysql_fetch_array($result)){ echo $row['PrName']; } } ?> </table> </div> <?php include("footer.inc.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881380 Share on other sites More sharing options...
NickG21 Posted July 23, 2009 Author Share Posted July 23, 2009 also i've tried other syntax for the same query that seemed to go through and i would get either an UNEXPECTED_T_STRING on the same line or the same Parse error on line 27, the query inside the while{} loop thanks for your help, Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881385 Share on other sites More sharing options...
tbare Posted July 23, 2009 Share Posted July 23, 2009 it's the single quotes in . $_COOKIE['PHPSESSID'] . the first single quote is finishing the single quote before the . Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881387 Share on other sites More sharing options...
tbare Posted July 23, 2009 Share Posted July 23, 2009 ... or rather start the query with a ' instead of a " you have your singles and doubles reversed in the first query Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881388 Share on other sites More sharing options...
thebadbad Posted July 23, 2009 Share Posted July 23, 2009 You're mixing single and double quotes on the longest line, and missing a single quote in the second query. You should also run the variables through mysql_real_escape_string() before using them in a query. Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881389 Share on other sites More sharing options...
gevans Posted July 23, 2009 Share Posted July 23, 2009 This line $sqlCCUpdate = "UPDATE tblCustomer set CuCCType = '" . $CCardType . "', CuCCNum = '" . $CCNum . "', CuCCSVC = '" . $CCCSV . "', CCExpDate= '" . $CCYear . "',CCName='" . $CCName . '" WHERE CuSessID = "' . $_COOKIE['PHPSESSID'] . '"; should be $sqlCCUpdate = "UPDATE tblCustomer set CuCCType = '" . $CCardType . "', CuCCNum = '" . $CCNum . "', CuCCSVC = '" . $CCCSV . "', CCExpDate= '" . $CCYear . "',CCName='" . $CCName . '" WHERE CuSessID = '" . $_COOKIE['PHPSESSID'] . "'"; You had the single and double quotes the wrong way round and you needed the closing double quote. EDIT: same problem in the query above it Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881391 Share on other sites More sharing options...
tbare Posted July 23, 2009 Share Posted July 23, 2009 first query fixed $sqlCCUpdate = "UPDATE tblCustomer set CuCCType = '" . $CCardType . "', CuCCNum = '" . $CCNum . "', CuCCSVC = '" . $CCCSV . "', CCExpDate= '" . $CCYear . "',CCName='" . $CCName . "' WHERE CuSessID = '" . $_COOKIE['PHPSESSID'] . "'"; edit: oops... try now Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881394 Share on other sites More sharing options...
NickG21 Posted July 23, 2009 Author Share Posted July 23, 2009 everything's working perfectly! thank you all for your help i appreciate it a ton! couldn't have done it without you (obviously!) Quote Link to comment https://forums.phpfreaks.com/topic/167001-solved-parse-error-in-duplicate-php/#findComment-881421 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.