baltar Posted May 20, 2014 Share Posted May 20, 2014 Ok I am using a book called The Joy of Php, but it the sample code is missing from its website, so I am rewriting it. Anyway I have run into a parsing error, but my code is a spot match for the book code. Can someone help me? the error is : Parse error: syntax error, unexpected 'Error' (T_STRING), expecting ',' or ';' in C:\wamp\www\submitcar.php on line 46 The code snippet is: /*try to insert the new car into the db */ if ($result=$mysqli->query($query)) { echo "<p> you have successfully entered $Make $model into the db.</P> } else { echo "Error entering $VIN into db:" . mysql_error()."<br>"; } $mysqli->close(); Please help...I have no idea where my error is. I have the gosh darn semicolon after <br>! Quote Link to comment https://forums.phpfreaks.com/topic/288617-newbie-parsing-error/ Share on other sites More sharing options...
requinix Posted May 20, 2014 Share Posted May 20, 2014 (edited) Take a look at the code in your post. See all that green? Green stuff is supposed to be a string but it's clearly showing some stuff as strings when it shouldn't (and vice versa). Find the place where it starts coloring incorrectly and you'll find where the problem is. Oh, and get yourself an IDE. Like Netbeans or PhpStorm. They can tell you exactly where and what problems are in your code, and offer many other features beyond that. Edited May 20, 2014 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/288617-newbie-parsing-error/#findComment-1480141 Share on other sites More sharing options...
baltar Posted May 20, 2014 Author Share Posted May 20, 2014 Hey all - I can't edit the original OM, but I managed to fix that error. I was missing a " and a ; in line 44. But now I get more error messages that are clearly above my pay grade. So I am making the entire code I have available. Please help me. <html> <head> <title>Car Saved</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php //capture values posted to this php program from the text fields in teh form $VIN=mysql_real_escape_string($_POST['VIN']); $Make=mysql_real_escape_string($_POST['Make']); $Model=mysql_real_escape_string($_POST['Model']); //Build a SQL Query using the values from above $query ="INSERT INTO Inventory (VIN, Make, Model) VALUES( '$VIN', '$Make', '$Model' )"; //Print the queryto the browser so you can see it echo ($query. "<br>"); $mysqli = new mysqli('localhost', 'root', NULL, 'db_name'); /*check connection*/ if (mysqli_connect_error()) { printf("Connect falied: %s\n", mysqli_connect_error()); exit(); } echo 'Connected successfully to mySQL <BR>'; //select db to work with $mysqli->select_db("cars"); echo ("Selected the cars database. <br>"); /*try to insert the new car into the db */ if ($result=$mysqli->query($query)) { echo "<p> you have successfully entered $Make $model into the db.</P>"; } else { echo "Error entering $VIN into db:" . mysql_error()."<br>"; } $mysqli->close(); ?> </body> </html> I follow the code. I still can't get it to run. Very frustrating...!!! Quote Link to comment https://forums.phpfreaks.com/topic/288617-newbie-parsing-error/#findComment-1480142 Share on other sites More sharing options...
baltar Posted May 20, 2014 Author Share Posted May 20, 2014 I should have mentioned but there is a preceding form through which the data is entered. The data get entered properly and I can see it in phpmyadmin. But I get a undefined variable error for line 21 '$Model'; I can't figure this out... please help. Quote Link to comment https://forums.phpfreaks.com/topic/288617-newbie-parsing-error/#findComment-1480144 Share on other sites More sharing options...
requinix Posted May 21, 2014 Share Posted May 21, 2014 But I get a undefined variable error for line 21 '$Model';I don't see how that's possible since you define it in the statement immediately before that line. Did you post your exact code? What is the exact error message? Quote Link to comment https://forums.phpfreaks.com/topic/288617-newbie-parsing-error/#findComment-1480349 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.