Page 1 of 1

[SOLVED] inserting data into a mysql database

Posted: Thu Mar 04, 2004 4:17 pm
by goblinhybrid
Here is my code. It says there is a parse error around line 20 but im not experienced to enough to see it.

Code: Select all

<?php
$datetime = date("m.d.y\ H:i:s");
$Location = $_POST['Location'];
$Area = $_POST['Area'];
$Title = $_POST['Title'];
$Author = $_POST['Author'];
$Data = $_POST['Data'];

echo $Area;

$dbh=mysql_connect ("localhost", "xskate_reviews", "password") or die ('There was an error with the database: ' . mysql_error());
mysql_select_db ("xskate_reviews"); 

if ($Area == "Parks")
{
$query = "INSERT INTO `Parks` VALUES ('', '$Title', '$Location', '$Author', '$Data', NOW( ));"
}

if ($Area == "Street")
{
$query = "INSERT INTO `Street` VALUES ('', '$Title', '$Location', '$Author', '$Data', NOW( ));"
}

if ($Area == "Tricks")
{
$query = "INSERT INTO `Tricks` VALUES ('', '$Title', '$Author', '$Data', NOW( ) );"
}

mysql_query($query);

mysql_close();
?>
Cheers

Posted: Thu Mar 04, 2004 5:30 pm
by andre_c
the semicolon needs to be at the end of the line (after the closing double quotes) on each of the queries

Posted: Thu Mar 04, 2004 5:32 pm
by Weirdan
place the semicolon after the closing quote in all of that lines:

Code: Select all

$query = "INSERT INTO `Parks` VALUES ('', '$Title', '$Location', '$Author', '$Data', NOW( ));"
//should be
$query = "INSERT INTO `Parks` VALUES ('', '$Title', '$Location',  '$Author', '$Data', NOW( ))";

Posted: Sat Mar 06, 2004 6:42 am
by goblinhybrid
cheers. dumb mistake...