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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.