PHP Insert of session variable

I have a form that collects data from the end user inputting the data. I also have a session script to check if the end user logged in so that the page will display or forward them somewhere else.

The form page will go to a INSERT.php which inserts the form variables into the database. What I need to do is INSERT the session variable which is the username into the database. But I'm getting an error message.

Here is the error message;

Parse error: syntax error, unexpected ',' in /home2/thstew/public_html/insert.php on line 17

Now if I run the same POST Variables without the session variable it works.


Thanks,
Jeff
/// This code is the session variable on the form page// 
<?php
 
 
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) {
header("location: http://www.google.com");
exit();
}
 
?>
 
//This code is the INSERT STATEMENT //
 $sql="INSERT INTO oetable_backup(entry_date,territory,principle,customer,po,part_no,qty,initial_sale,due_to_ship,comm,type_ind,location_ind)
VALUES
('$_POST[entry_date]','$_POST[territory]','$_POST[principle]','$_POST[customer]','$_POST[po]','$_POST[part_no]','$_POST[qty]','$_POST[initial_sale]','$_POST[due_to_ship]','$_POST[comm]','O','$_POST[SESS_MEMBER_ID]')";

Open in new window

jseaman12Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

syedasimmeesaqCommented:
Try this

$sql="INSERT INTO oetable_backup(entry_date,territory,principle,customer,po,part_no,qty,initial_sale,due_to_ship,comm,type_ind,location_ind)
VALUES
('$_POST[entry_date]','$_POST[territory]','$_POST[principle]','$_POST[customer]','$_POST[po]','$_POST[part_no]','$_POST[qty]','$_POST[initial_sale]','$_POST[due_to_ship]','$_POST[comm]','O','$_SESSION[SESS_MEMBER_ID]')";
0
jseaman12Author Commented:
I've tried that one before and receive the same error message. So that doesn't work.
0
syedasimmeesaqCommented:
what error message are you getting. Could you be more specific.
Thanks
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

syedasimmeesaqCommented:
Please try the code below. Also can you tell me if O in this statement is at right place?  Its not getting any value.
$sql="INSERT INTO oetable_backup(entry_date,territory,principle,customer,po,part_no,qty,initial_sale,due_to_ship,comm,type_ind,location_ind)
VALUES
('".$_POST['entry_date']."', '".$_POST['territory']."','".$_POST['principle']."','".$_POST['customer']."','".$_POST['po']."','".$_POST['part_no']."','".$_POST['qty']."','".$_POST['initial_sale']."','".$_POST['due_to_ship']."','".$_POST['comm']."','".O."','".$_POST['SESS_MEMBER_ID']."')";

Open in new window

0
syedasimmeesaqCommented:
Better yet, if I would be you, I would try to define the varables first and then use them, instead of using post in insert query.
please find the code below.
Hope that helps

<?php
 
 
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) {
header("location: http://www.google.com");
exit();
}
else
{ 
$entrydate = $_POST['entry_date'];
$territory = $_POST['territory'];
$principle = $_POST['principle'];
$customer  = $_POST['customer'];
$po = $_POST['po'];
$part_no = $_POST['part_no'];
$qty = $_POST['qty'];
$initial_sale = $_POST['initial_sale'];
$due_to_ship = $_POST['due_to_ship'];
$comm = $_POST['comm'];
$O == "0";
$SESS_MEMBER_ID = $_POST['SESS_MEMBER_ID']; 
 
 
$sql="INSERT INTO oetable_backup(entry_date, territory, principle, customer, po, part_no, qty, initial_sale, due_to_ship, comm, type_ind, location_ind)
VALUES
('".$entry_date."', '".$territory."','".$principle."','".$customer."','".$po."','".$part_no."','".$qty."','".$initial_sale."','".$due_to_ship."','".$comm."','".$O."','".$SESS_MEMBER_ID."')";
}
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jseaman12Author Commented:
I didn't get the answer I needed but that's ok. Thanks for your help and support.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.