underknown Posted October 20, 2010 Share Posted October 20, 2010 Parse error: syntax error, unexpected T_VARIABLE in Z:\www\website\center.php on line 35 This error is coming up when attempting to run the following code. line 35 is the one containing the $query statement. :/ <?php include("header.php"); ?> <?php include("topmenu.php"); ?> <?php include("menu.php"); ?> <?php include("news.php"); ?> <?php include("links.php"); ?> <?php include("info.php"); ?> <div id="column2"> <h1>introduction</h1> <!-- **** INSERT PAGE CONTENT HERE **** --> <p> This page can be used to insert new customers. </p> <?php //Check Form Submission if (isset($_POST['Create'])) { //Extract Values $surname = $_POST['surname']; $givenname = $_POST['given_name']; $address = $_POST['address']; $city = $_POST['city']; $province = $_POST['province']; $postalcode = $_POST['postal_code']; $phonenumber = $_POST['phone_number']; //Connect to Database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PW, DB_NAME) //Insert Query $query = "INSERT INTO customers (surname, given_name, address, city, province, postal_code, phone_number) VALUES ('$surname', '$givenname', '$address', '$city', '$province', '$postalcode', '$phonenumber') "; //Execute Query mysqli_query($dbc, $query) or die ("Error inserting data."); //Close Connection mysqli_close($dbc) //Confirm echo 'Customer Added.<br />'; } ?> <!-- Create the Form to Add Users --> <form method = "post" action = "<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="surname">Surname:</label><input type="text" id="surname" name="surname"><br /> <label for="given_name">First Name:</label><input type="text" id="given_name" name="given_name"><br /> <label for="address">Address:</label><input type="text" id="address" name="address"><br /> <label for="city">City:</label><input type="text" id="city" name="city"><br /> <label for="province">Province:</label><input type="text" id="province" name="province"><br /> <label for="postal_code">Postal Code:</label><input type="text" id="postal_code" name="postal_code"><br /> <label for="phone_number">Phone Number:</label><input type="text" id="phone_number" name="phone_number"><br /> <input type = "submit" name = "Create" value = "Create" /> </form> </div> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/216313-error/ Share on other sites More sharing options...
BlueSkyIS Posted October 20, 2010 Share Posted October 20, 2010 missing semi-colon at end of $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PW, DB_NAME) Link to comment https://forums.phpfreaks.com/topic/216313-error/#findComment-1124164 Share on other sites More sharing options...
underknown Posted October 20, 2010 Author Share Posted October 20, 2010 Thank you! Link to comment https://forums.phpfreaks.com/topic/216313-error/#findComment-1124165 Share on other sites More sharing options...
fortnox007 Posted October 20, 2010 Share Posted October 20, 2010 Thank you! your missing one after your close connection too Link to comment https://forums.phpfreaks.com/topic/216313-error/#findComment-1124166 Share on other sites More sharing options...
Pikachu2000 Posted October 20, 2010 Share Posted October 20, 2010 Don't use $_SERVER['PHP_SELF'] to submit a form to itself; it presents an XSS vulnerability. Either use action="" or name the script explicitly. Link to comment https://forums.phpfreaks.com/topic/216313-error/#findComment-1124168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.