Hi, I need to pull out some info from a table in my data base using php. <?php $result = mysql_query("SELECT 'giftlog.name', 'giftlog.image' FROM giftlog") LEFT JOIN gifts USING (giftid) WHERE giftlog.recipientid = " . $userid" ?> PHP: This is the code but it doesnt work.....lim a noob at the whole sql/php thing.
You must use following code $result = mysql_query("SELECT 'giftlog.name' AS name, 'giftlog.image' AS image FROM giftlog LEFT JOIN gifts USING (giftid) WHERE giftlog.recipientid = " . $userid); $row = mysql_fetch_assoc($result)); echo $row['name']; echo $row['image']; PHP:
I get this - Parse error: parse error, unexpected ')' in /home/p/i/picturest/public_html/mygifts.php on line 5
there is a problem with your $result try this $result = mysql_query("SELECT `giftlog`.`name` AS name, `giftlog`.`image` AS image FROM `giftlog` LEFT JOIN `gifts` ON `giftlog`.`giftid` = `gifts`.`giftid` WHERE `giftlog`.`recipientid` = " . $userid); PHP: However, i see you dont' pull any fields from the gifts table, so i can't see why you are using the LEFT JOIN
If you can provide access to your database for example via phpMyAdmin maybe I will be able to help you.