Alright, this is pitiful.
People can come to my site, sign up, and their information is stored in a USERS table. They have a unique (auto-increment, primary key) id, username, first name, last name, etc. Now, I have a wishlist for them to fill out when logged in, which uses the table WISHES.
Now, when I want to store their information in the WISHES table, I want their id (a primary, auto-incrementing key from the USERS table to be placed in the WISHES table as well, under w_id). Please take a look at this code for a sec, and i'll ask my question below it.
<?php $idiot = $db_object->query("SELECT id FROM users WHERE username = ".$db_object->quote($_SESSION['username']));
$idiot = $idiot->fetchRow();
// now we can add them to the database.
$query = "INSERT INTO wishes(
w_id,
w_username,
w_wish1,
w_wish2,
w_wish3,
w_wish4,
w_wish5,
w_wish6)
VALUES (
"$idiot['id']",
'".$_SESSION['username']."',
'".$_POST['w1']."',
'".$_POST['w2']."',
'".$_POST['w3']."',
'".$_POST['w4']."',
'".$_POST['w5']."',
'".$_POST['w6']."')";
mysql_query($query) or die(mysql_error());
?>
Alright, I get a parse error on line 230:
"$idiot['id']",
when I try inputting their unique ID (a primary key) to the wishes table under the row called w_id.
What is wrong with the code? Sorry guys, I'm kind of new to PHP, but I would love your help.