Hi, I have an issue with a multi Query where the error i get is: Parse error: syntax error, unexpected 'Cant' (T_STRING) in C:\xampp\htdocs\cars\BuyCar2.php on line 45 Been looking and I cannot work out what is wrong, code: PHP: <?php session_start(); $sessionstarted = 1; if(isset($_SESSION['userid'])) { // Allow car to be bought // Get Variables $carIndex = $_POST['carIndex']; $UserID = $_SESSION['userid']; $title= $_POST['title']; $firstName= $_POST['firstName']; $lastName= $_POST['lastName']; $contacthome= $_POST['contacthome']; //int $contactmobile= $_POST['contactmobile']; //int $addressLine1= $_POST['addressLine1']; $addressLine2= $_POST['addressLine2']; $addressCounty= $_POST['addressCounty']; $addressPostCode= $_POST['addressPostCode']; $ccNumber = $_POST['ccnumber']; $ccSecurity = $_POST['ccsecurity']; //Connect to server $odbc = mysql_connect('localhost', 'root', '') or die ("Can't connect to server"); //Connect to database mysql_select_db('cars', $odbc) or die ("Can't connect to database"); // text: '" blah variable "' // numerical: ' boo im a variable ' $sql = "INSERT INTO purchase VALUES (DEFAULT, ".$carIndex.", ".$UserID.", '".$title."', '".$firstName."', '".$lastName."', ".$contacthome.", ".$contactmobile.", '".$addressLine1."', '".$addressLine2."', '".$addressCounty."', '".$addressPostCode."', ".$ccNumber.", ".$ccSecurity."); $result = mysql_query($sql, $odbc) or die ("Cant run query"); if($result) { //Connect to server $odbc3 = mysql_connect('localhost', 'root', '') or die ("Can't connect to server"); //Connect to database mysql_select_db('cars', $odbc3) or die ("Can't connect to database"); // text: '" blah variable "' // numerical: ' boo im a variable ' $sql3 = "UPDATE `cars`.`cars` SET sold = "1", WHERE carIndex = ".$carIndex." "; $result3 = mysql_query($sql, $odbc) or die ("Can't run query"); if($result3) { //Connect to server $odbc4 = mysql_connect('localhost', 'root', '') or die ("Can't connect to server"); //Connect to database mysql_select_db('cars', $odbc3) or die ("Can't connect to database"); // text: '" blah variable "' // numerical: ' boo im a variable ' $sql4 = "Select * From cars WHERE carIndex = ".$carIndex." "; $result4 = mysql_query($sql, $odbc) or die ("Can't run query"); // Check data is returned (There are results, not empty) if(mysql_num_rows($result4) == 0) //Count rows returned, of 0 (no data) do the following: { //Echo puts text on screen echo "<h4> No records were returned, search again </h4>"; } else { $count = 0; // to count number of records returned //Display data that is returned, choose formatting while($row=mysql_fetch_object($result4)) // gets one row from the returned query data at a time then displays it { ?> <!DOCTYPE html> <html> <head> <title>Purchase Car</title> <link href="CSS/default.css" rel="stylesheet" type="text/css"> <style type="text/css"> </style> </head> <body> <div id="container"> <!-- Start of container Div --> <?php include 'Templates/AdminHeader.php' ?> <div id="maincontent"><!-- Start of Main Content Div--> <div id="admintext"> <h3> <?php echo "Car Purchased"; ?> </h3> <p>You will need to bring the following information with you:</p> <p>Driving license</p> <p>Print out of this page</p> <p>Insurance, we recomend one of these: <a href="www.confused.com/car-insurance">Confused.com</a> or <a href="www.moneysupermarket.com/car-insurance/">Money Supermarket</a> or <a href="www.directline.com/">Direct Line</a></p> <br> <h3>Additional information about the car:</h3> <p>VIN: <?php echo $carIndex;?></p> <p>Dealer: <?php echo $row->dealer;</p> <p>Town: <?php echo $row->town;</p> <p>Region: <?php echo $row->region;</p> <p>Telephone: <?php echo $row->telephone;</p> </div> </div><!-- End of Main Content Div--> <?php include 'Templates/Footer.php' ?> </div> <!-- End of container Div --> </body> </html> <?php } } } } else { ?> <!DOCTYPE html> <html> <head> <title>Login Required</title> <!-- <META HTTP-EQUIV=REFRESH CONTENT="5; URL=http://localhost/cars/login.php"> --> <link href="CSS/default.css" rel="stylesheet" type="text/css"> <style type="text/css"> </style> </head> <body> <div id="container"> <!-- Start of container Div --> <div id="header"> <!-- Start of Header Div--> <div id="logo"><!-- Start of Logo Div--> <img alt="Logo" src="Images/logo.png"> </div><!-- End of Logo Div--> <div id="companyname"><!-- Start of company name Div--> <h1 id="companynametext">voiture</h1> </div> <!-- End of company name Div--> <div id="socialmedia"> <!-- start of social media Div--> <div id="socialmediatext"> <!-- start of social media text Div--> <p>Follow us on:</p> </div> <!-- End of social media text Div--> <div id="socialmediaimages"><!-- start of social media images Div--> <a href="http://www.facebook.com" ><img alt="facebook" src="Images/facebook.png" HEIGHT="20" WIDTH="20"></a> <a href="http://www.linkedin.com" ><img alt="linked in" src="Images/linkedin.png" HEIGHT="20" WIDTH="20"></a> <a href="http://www.twitter.com" ><img alt="twitter" src="Images/twitter.png" HEIGHT="20" WIDTH="20"></a> </div><!-- end of social media images Div--> </div> <!-- End of social media Div--> </div> <!-- End of Header Div--> <div id="navigation"> <!-- start of navigation Div--> <ul id="navul"> <!-- Navigation Table --> <li class="navli"><a class="mainnav" href="Index.php">Home</a></li> <li class="navli"><a class="mainnav" href="Login.php">Login</a></li> </ul> </div> <!-- End of navigation Div--> <div id="maincontent"><!-- Start of Main Content Div--> <div id="admintext"> <h3> Login Required </h3> <p>You are required to login before being able to purchase this car</p> <p>You will be automatically forwarded to the Login page</p> <p>If your browser does not support this please <a href="Login.php"> click here </a></p> <p>Once logged in please browse back to the car and click buy again</p> </div> </div><!-- End of Main Content Div--> <div id="footer"><!-- Start of footer Div--> <table id="footertable"> <tr> <td><p> Copyright Jason Field |</p></td> <td><p> <a href="tandcs.php">Terms and Conditions</a> | </p></td> <td><p> <a href="Contact.php">Contact Us</a> | </p></td> <td><p> <a href="about.php">About us</a> | </p></td> </tr> </table> </div> <!-- End of footer Div--> </div> <!-- End of container Div --> </body> </html> <?php } And DefaultHeader incase you are curious: PHP: <?php if(isset($sessionstarted)) { // work around for buy car due to session start being called before this } else { Session_start(); } if(isset($_SESSION['userid'])) { $userid = $_SESSION['userid']; // MYSQL_Connect is a function to run odbc for mysql $odbc2 = mysql_connect ('localhost', 'root', '') or die ("Could not contact server, please contact administrator, Is Xampp running?"); // Server, User, Password //Connect to Database mysql_select_db('cars',$odbc2) or die ("Database not found"); //Database name, Mysql_Connect variable // Define SQL Statement to retrieve all records $sql2 = "SELECT * FROM member Where UserID = '".$userid."'"; // Retrieve result from SQL Statement $result2 = mysql_query($sql2, $odbc2) or die ("Cannot run query, learn to spell douchebag!"); // Check data is returned (There are results, not empty) if(mysql_num_rows($result2) == 0) //Count rows returned, of 0 (no data) do the following: { } else { //Display data that is returned, choose formatting while($row2=mysql_fetch_object($result2)) // gets one row from the returned query data at a time then displays it { ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div id="header"> <!-- Start of Header Div--> <div id="logo"><!-- Start of Logo Div--> <img alt="Logo" src="Images/logo.png"> </div><!-- End of Logo Div--> <div id="companyname"><!-- Start of company name Div--> <h1 id="companynametext">voiture</h1> </div> <!-- End of company name Div--> <div id="socialmedia"> <!-- start of social media Div--> <div id="socialmediatext"> <!-- start of social media text Div--> <p>Follow us on:</p> </div> <!-- End of social media text Div--> <div id="socialmediaimages"><!-- start of social media images Div--> <a href="http://www.facebook.com" ><img alt="facebook" src="Images/facebook.png" HEIGHT="20" WIDTH="20"></a> <a href="http://www.linkedin.com" ><img alt="linked in" src="Images/linkedin.png" HEIGHT="20" WIDTH="20"></a> <a href="http://www.twitter.com" ><img alt="twitter" src="Images/twitter.png" HEIGHT="20" WIDTH="20"></a> </div><!-- end of social media images Div--> <div id="LoginWelcome"> <h6 id="loginwelcometext">Welcome <?php echo $row2->firstName;?></h6> </div> </div> <!-- End of social media Div--> </div> <!-- End of Header Div--> <div id="navigation"> <!-- start of navigation Div--> <ul id="navul"> <!-- Navigation Table --> <li class="navli"><a class="mainnav" href="Index.php">Home</a></li> <li class="navli"><a class="mainnav" href="SearchHome.php">Search</a></li> <li class="navli"><a class="mainnav" href="Gallery">Gallery</a></li> <li class="navli"><a class="mainnav" href="Logout.php">Log Out</a></li> </ul> </div> <!-- End of navigation Div--> </body> </html> <?php } } } else { ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div id="header"> <!-- Start of Header Div--> <div id="logo"><!-- Start of Logo Div--> <img alt="Logo" src="Images/logo.png"> </div><!-- End of Logo Div--> <div id="companyname"><!-- Start of company name Div--> <h1 id="companynametext">voiture</h1> </div> <!-- End of company name Div--> <div id="socialmedia"> <!-- start of social media Div--> <div id="socialmediatext"> <!-- start of social media text Div--> <p>Follow us on:</p> </div> <!-- End of social media text Div--> <div id="socialmediaimages"><!-- start of social media images Div--> <a href="http://www.facebook.com" ><img alt="facebook" src="Images/facebook.png" HEIGHT="20" WIDTH="20"></a> <a href="http://www.linkedin.com" ><img alt="linked in" src="Images/linkedin.png" HEIGHT="20" WIDTH="20"></a> <a href="http://www.twitter.com" ><img alt="twitter" src="Images/twitter.png" HEIGHT="20" WIDTH="20"></a> </div><!-- end of social media images Div--> </div> <!-- End of social media Div--> </div> <!-- End of Header Div--> <div id="navigation"> <!-- start of navigation Div--> <ul id="navul"> <!-- Navigation Table --> <li class="navli"><a class="mainnav" href="Index.php">Home</a></li> <li class="navli"><a class="mainnav" href="SearchHome.php">Search</a></li> <li class="navli"><a class="mainnav" href="Gallery">Gallery</a></li> <li class="navli"><a class="mainnav" href="Login.php">Login</a></li> </ul> </div> <!-- End of navigation Div--> </body> </html> <?php } ?> Thank you for your help in advanced All variables are posted from the previous page or grabbed from sessions
I was going to point that out... your issue is here: Code: ".$ccSecurity."); $result = mysql_query($sql, $odbc) or die ("Cant run query"); should be Code: ".$ccSecurity.")"; $result = mysql_query($sql, $odbc) or die ("Cant run query"); you made that mistake twice from what I can see quickly now. Syntax highlighting Eff Tee Double-You
No I'm not as it is for an assignment which doesn't specify that and with everything else extra I have included I haven't had time to do it.
Are you using any specific IDE's for this? I'd recommend NetBeans (PHP edition). Has full blown syntax highlighting, code completion and syntax checking built in.