SuiGenerisMN Posted September 11, 2017 Share Posted September 11, 2017 I am sure to get some flack for this, but I have searched google, and this forum, and found some great advice, but I am still getting the "unexpected end of file" error. Any assistance is appreciated. Background, I have an HTML form that submits an email to me and I would also like to send the form data to a DB. The emailform.php has the include ("loaddb.php"); at the top. The emailform.php works fine, but the data never gets entered into the DB. <?php $servername = “localhost”; $username = “”; $password = “”; $dbname = “”; $tblname = “”; If (isset($_POST[‘submit’])) { $conn = mysqli_connect($servername, $username, $password); if (!$conn) { die('Could not connect: ' . mysqli_error()); } mysqli_select_db($dbname, $conn); $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email_from = $_POST['email']; $telephone = $_POST['telephone']; $first_name = mysqli_real_escape_string($first_name); $last_name = mysqli_real_escape_string($last_name); $email = mysqli_real_escape_string($email); $telephone = mysqli_real_escape_string($telephone); $query = " INSERT INTO $dbname.$tblname(‘ID’, ‘First’, ‘Last’, ‘Email’, ‘Phone’) VALUES (NULL, '$first_name', '$last_name', '$email', '$telephone');”; } mysqli_close($conn); ?> I checked whitespace, all brackets appear to be closing. Error shows as last line with the closing "?>" and I am stumped. Again, sorry for "another one of these error" questions but I just cannot get this to work and have been trying everything I can think of. Quote Link to comment https://forums.phpfreaks.com/topic/304951-another-sigh-unexpected-end-of-file-error/ Share on other sites More sharing options...
ginerjm Posted September 11, 2017 Share Posted September 11, 2017 Review very carefully all of your braces ( { } ) to be sure they are paired up and in the proper places. Quote Link to comment https://forums.phpfreaks.com/topic/304951-another-sigh-unexpected-end-of-file-error/#findComment-1551152 Share on other sites More sharing options...
Solution kicken Posted September 11, 2017 Solution Share Posted September 11, 2017 Some of your quote marks are of the "smart quotes" variety which won't work. Replace them with standard ascii quotes. Quote Link to comment https://forums.phpfreaks.com/topic/304951-another-sigh-unexpected-end-of-file-error/#findComment-1551153 Share on other sites More sharing options...
SuiGenerisMN Posted September 12, 2017 Author Share Posted September 12, 2017 Thank you kicken, that solved the errors completely. Crazy I missed that piece. Appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/304951-another-sigh-unexpected-end-of-file-error/#findComment-1551169 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.