Jump to content

[SOLVED] Script gives error.


will35010

Recommended Posts

I'm trying to use this script to insert data into a database. I'm very new to php so thanks ahead of time.

 

ERROR: Parse error: syntax error, unexpected T_VARIABLE in /var/www/playhouse2/admin/addevent/addevent.php on line 4

 

SCRIPT:

 

<? php

//PHP script to add events to database

 

$dbhost = 'localhost';

$dbuser = 'playhouse';

$dbpass = 'playhouse1';

$dbname = 'playhouse';

 

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die       

                    ('Error connecting to mysql');

 

mysql_select_db($dbname);

//Date Varible Assignment

$month = $_post['element_1_1'];

$day = $_POST['element_1_2'];

$year = $_POST['element_1_3'];

 

//Time Varible Assignment

$hour = $_POST['element_2_1'];

$min = $_POST['element_2_2'];

$ampm = $_POST['element_2_4'];

 

//Event Name & Description Varible Assignment

$name = $_POST['element_3'];

$desc = $_POST['element_4'];

 

//Generate a uniqueID

$eventID = $db->nextID('playhouse');

 

//Send the Form Data to the Database

$query = "INSERT INTO events (eventID, eventmonth, eventday, eventyear, hour, minute, ampm, eventname, eventdescription) VALUES ($eventID, $month, $day, $year, $hour, $min, $ampm, $name, $desc)";

 

mysql_query($query) or die('Error, insert query failed');

 

mysql_close($conn);

?>

Link to comment
https://forums.phpfreaks.com/topic/130958-solved-script-gives-error/
Share on other sites

Wow! That's pretty bad. I knew that error was usually a curly brace or something missing. Thanks.

 

On line 28 I'm trying to get it to generate a unique id for a autoinc field on the table. It gives this error:

 

Fatal error: Call to a member function nextID() on a non-object in /var/www/playhouse2/admin/addevent/addevent.php on line 28

 

If I skip this would the database generate it's own ID? If so, how would I skip it on the insert statement? Just leave it blank?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.