0

I am trying to make a website that will take data from a html form and add it to a sql database

post.html:

<form action="send_post.php" method="post">
<h3>ID:</h3>
<input type="text" name="id">
<h3>Name:</h3>
<input type="text" name="name">
<h3>Surname:</h3>
<input type="text" name="surname">
<input type="submit">

send_post.php

<?php  
$connect = mysqli_connect("myhost","myusername","mypassword","myDB");
mysqli_query($connect,"INSERT INTO test_table (id, name, surname)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')"
?>

I have hosted it here

However when I try it says that there is a unexpected semicolon in a line where there is not a semi colon. How do I fix this?

7
  • 1
    It says the error is on line 7, however you only posted 5 lines of code? Commented Feb 8, 2015 at 17:57
  • Now go and change your passwords Commented Feb 8, 2015 at 17:57
  • Check once again on what line, in what file and what the exact error. And post relevant code. Commented Feb 8, 2015 at 17:59
  • I had some comments in which I deleted, I have updated it, it now says line 5 Commented Feb 8, 2015 at 17:59
  • mysqli_query should have closing ) Commented Feb 8, 2015 at 17:59

1 Answer 1

3

Missing ); Use this...

mysqli_query($connect,"INSERT INTO test_table (id, name, surname) VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.