we are working on a school project. We are trying to use some simple MySQL to store data from a single HTML text form into a MySQL database.
My HTML looks like this:
<form action="sql/tilmeld-sms.php" method="post">
<h2>Tilmelding til SMS:</h2>
<input type="text" name="sms">
<input type="submit" value="Submit">
</form>
Our SQL looks like this:
<?php
$connect = mysql_connect(“localhost”, “ODBC”, “”); if (!connect) { die('Connection Failed: ' . mysql_error()); { mysql_select_db(“database_name”, $connect);
$user_info = “INSERT INTO sms (sms) VALUES ('$_POST[sms]')”; if (!mysql_query($user_info, $connect)) { die('Error: ' . mysql_error()); }
echo “Your information was added to the database.”;
mysql_close($connect);
?>
When we run this on our localhost, we get a syntax error on line 4. Which means there is something wrong with this line of code:
$user_info = “INSERT INTO sms (sms) VALUES ('$_POST[sms]')”; if (!mysql_query($user_info, $connect)) { die('Error: ' . mysql_error
We know this is very simple MySQL. But its the first time we use it, and the first time we try to store data from a HTML form into a mysql database.
Other info:
- Databasename: projekt32
- Databasehost: localhost
- Username: ODBC (We read this is the general username for localhost on Windows)
- Password: no password on localhost we read
- Tablename: sms
EDIT: This is the error code we get:
Parse error: syntax error, unexpected 'INTO' (T_STRING) in C:\xampp\htdocs\projekt-3-2\sql\tilmeld-sms.php on line 4
EDIT2: This is a school project, and MySQL is part of this project. We wont pass without using it, so suggesting other things we can do than MySQL wont work but thanks anyway!