i did a little tutorial on how to update information on your site using a form, php and mysql:
the tutorial said first create your database table using this script:
<?
//Our PHP/MYSQL page.
//MySQL Variables. Edit where necessary
$host = "localhost";
$login_name = "user";
$password = "pass";
//Connecting to MYSQL
MySQL_connect("$host","$login_name","$password");
//Select the database we want to use
MySQL_select_db("first_database") or die("Could not select database");
//Execute QUERY to create addressbook table
//We'll name the query $sql
$sql = "CREATE TABLE addressbook (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
Email CHAR(50) NOT NULL,
First_Name CHAR(25) )
";
//Run the above query
$result = mysql_query($sql);
if ($result) {
echo("Table created successfully");
} else {
echo("error when creating table");
}
//Close the connection to MySQL
MySQL_close()
?>
and then save it as: create.php so after putting in my details i run the script and everythin was fine, i checked the table in my database and it was fine also, so then it goes onto say how to create the form using this code:
<form action="script.php">
Name: <input type="text" name="Name"><br>
Email: <input type="text" name="Email">
<input type="submit" name="submit" value="submit">
</form>
i saved this as form.php as shown in the tutorial, and then the next bit is the script.php file which you had to use this code below:
<?
//Our PHP/MYSQL page.
//This script takes the data from the form
//fields and adds them to specified parts
//parts of the database
//MySQL Variables. Edit where necessary
$host = "localhost";
$login_name = "user";
$password = "pass";
//Connecting to MYSQL
MySQL_connect("$host","$login_name","$password");
//Select the database we want to use
MySQL_select_db("first_database") or die("Could not select database");
//Assign contents of form to variables
$name = $_POST['Name'];
$email = $_POST['Email'];
$sql = "INSERT INTO addressbook SET
Email = "$email",
First_Name = "$name"
");
$result = mysql_query($sql);
//Code to check if statement executed properly and display message
if ($result) {
echo("Email and Name successully added");
} else {
echo("An error has occured");
}
//Close connection with MySQL
MySQL_close()
?>
so again i put my database and server details in and then uploaded everthing on my server, and before you say "is your server php4? the answer is yes".
Right anyway, i went to form.php and entered in the information which is name and email, then i clicked on "submit" and got this error:
[b]Parse error: parse error in /home/domains/musicvids.co.uk/user/htdocs/mysqltest/script.php on line 22[/b]
in my address bar this is shown:
[url]http://www.musicvids.co.uk/mysqltest/script.php?Name=dddddd&Email=fff@dd.com&submit=submit[/url]
....
can anyone help me please??