Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Parse Error with Insert Query - Newbie here so be gentle. :)
Old 05-05-2011, 12:50 AM Parse Error with Insert Query - Newbie here so be gentle. :)
Junior Talker

Posts: 1
Trades: 0
I am trying to insert some form data into a table and keep getting a Pharse error. I have successfully done so using another form and copied/adjusted the code to match the 2nd for but get the error. Not sure if it is because I am trying to submit decimal values and I am obviously missing something. Any help or recommendations would be appreciated!

Thanks!

PHP Code:
<?php
 session_start
();
 
 include(
"../includes/includes.php");
$sql "INSERT into price_details (courseid, 9holecostwkdy, 9holecostwknd, 18holecostwkdy, 18holecostwknd, cartfeewkdy, cartfeewknd, junior9holecostwkdy, junior9holecostwknd, junior18holecostwkdy, junior18holecostwknd, senior9holecostwkdy, senior9holecostwknd, senior18holecostwkdy, senior18holecostwknd, drivingrange)
 VALUES ('
$POST_[courseid]', '$POST_[9holecostwkdy]', '$POST_[9holecostwknd]', '$POST_[18holecostwkdy]', '$POST_[18holecostwknd]', '$POST_[cartfeewkdy]', '$POST_[cartfeewknd]', '$POST_[junior9holecostwkdy]', '$POST_[junior9holecostwknd]', '$POST_[junior18holecostwkdy]', '$POST_[junior18holecostwknd]', '$POST_[senior9holecostwkdy]', '$POST_[senior9holecostwknd]', '$POST_[senior18holecostwkdy]', '$POST_[senior18holecostwknd]', '$POST_[drivingrange]')";
 
if (!
mysql_query($sql))
   {
   die(
'Error: ' mysql_error());
   }
 echo 
"Course ID: $_POST[courseid] pricing options have been added successfully. <a href=\"layout_submission_form.php?courseid=$_POST[courseid]\">Click here to add course layout details.</a>";
  
exit();
 
?>

ERROR MESSAGE:

Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/mngolf/public_html/data/courses/pricing_submission.php on line 8

Last edited by chrishirst; 05-05-2011 at 06:16 AM..
rcortinmn is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-05-2011, 06:33 AM Re: Parse Error with Insert Query - Newbie here so be gentle. :)
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The keyname in the $_POST array should be enclosed in single quotes AND you should be "sanitising" user provided values rather than using post values directly in a query.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-05-2011, 06:45 AM Re: Parse Error with Insert Query - Newbie here so be gentle. :)
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
PHP Code:
# In the query, by all the
   
$POST_
# you probably meant 
   
$_POST

# And the index of an array should be a variable or a string, so
   
$_POST[courseid]
# should be
   
$_POST[$courseid]
# or
   
$_POST['courseid'
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Parse Error with Insert Query - Newbie here so be gentle. :)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31294 seconds with 12 queries