oops - my mistake. Change this line: $userid = (int)GET['userid']; PHP: to this: $userid = (int)$_GET['userid']; PHP: Brew
Again I get this: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Then I guess you have no gifts for that user. It's a bit difficult to debug without you showing exactly what the value of $userid is and what data you have in your database. Can you provide this ? Brew
Here is some data from the tables. Maybe a pic would have been better?! giftlogtable Logid Giftid Recipientid Fromid 7 1 nat12 Helen Edit Delete 10 1 nat12 helen Edit Delete 11 1 helen Nat12 Edit Delete 12 1 helen helen Edit Delete HTML: gifts table Giftid Name Image 1 Kiss <img src="/gifts/Kiss.png"> Edit Delete 2 Hot <img src="/gifts/hot.png"> Edit Delete 3 Leaf <img src="/gifts/leaf.png"> Edit Delete HTML:
Ok, so far- *user send info from the form into the giftlog table, info goes in fine. *When user tries to see what gifts have been sent to them they is an error.(many infact!)
And how are we supposed to help if we don't know what these errors are? Please post all error messages. And the exactly code you're using.
Ok here is every thing I have- Basic test form to submit data to table - <form action="gift.php" method="post"> <input type="text" name="giftid" value="$name"> <input type="text" name="recipientid" value="$recipientid"> <input type="text" name="username" value="$username"> <input type="submit" name="Submit" value="Submit" class="mybutton"> </form> HTML: <form action="gift.php">from above ! <? require ("config.php"); include("functions.php"); // Insert a row of information into the table "giftlog" mysql_query("INSERT INTO giftlog (Giftid, Recipientid,Fromid) VALUES('$giftid', '$recipientid', '$username' ) ") or die(mysql_error()); echo "Data Inserted!"; ?> PHP: To view gifts in member area - <? $username = (int)$_GET['username']; $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=" . $username); while ($row = mysql_fetch_assoc($result)) { echo $row['name']; echo $row['image']; } ?> PHP: error message- Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Also please not I have change userid to username, I am playing around with this so either change it back or ignore it.
OK, the problem seems to be that $userid is not a numeric value. Try replacing this: $userid = (int)$_GET['userid']; PHP: with this: $userid = mysql_real_escape_string( $_GET['userid'] ); PHP: and call your page like this: {page name}.php?userid=helen Brew
hhhmmm still getting the same error message - Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource. Would it change anything if I changed userid to username as thats is whats used on the site ?!
Yes, however if you are going to change it to this: $username = mysql_real_escape_string( $_GET['username'] ); PHP: The you will have to call the page like this: {page name}.php?username=helen Brew
Ok, but really that shouldnt effect it either way. ? Anyhow im still get the same message. - Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource ..