Thanks, I appreciate that.
I have another question, I've been learning PHP for about six weeks now, but it seems that I always seem to get confused when I try to enter
variables into my queries. And each time I get it working I feel like I finally understand, but then I end up having trouble again.
This time it's entering session values into my query.
Code: Select all
$query = "INSERT INTO
student_info
( sid,
first_name,
last_name,
sex,
reg_date,
dob,
school,
active,
medical_issues,
notes,
secret_classification,
last_update )
VALUES
( 'null',
'."$_SESSION['stud_info'][0]".',
'."$_SESSION['stud_info'][1]".',
'."$_SESSION['stud_info'][2]".',
now(),
'."$_SESSION['stud_info'][3]".',
'."$_SESSION['stud_info'][4]".',
'n',
'."$_SESSION['stud_info'][5]".',
'."$_SESSION['stud_info'][6]".',
'0',
'now()' ) " ;
$result = @mysql_query ($query); // Run the query.
I have tried both curly braces and brackets, but it just isn't working, I am getting the unexpected variable error message.
I feel like I shou;d have a handle on this already, but there's obviously something I'm missing. Do I need to assign the session value to a regular variable before inserting into my query? what am I doing wrong?