cruxaders Posted April 5, 2011 Share Posted April 5, 2011 can someone check if what the problem with my code $avatar2 = mysql_query("SELECT `users`.`imagelocation' FROM `users` `forum_replies` WHERE `users`.`id`= `forum_replies`.`uid`")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/ Share on other sites More sharing options...
Pikachu2000 Posted April 5, 2011 Share Posted April 5, 2011 What's happening with it? What errors is it returning? Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197289 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 You're missing a comma between your table names. Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197291 Share on other sites More sharing options...
cruxaders Posted April 5, 2011 Author Share Posted April 5, 2011 btw i forgot to tell i got 2 tables 1st table is users, with fields -id -username -imagelocation 2nd table is forum_replies with fields -id -uid -message what i want to do in sql is to get the image location.. $avatar2 = mysql_query("SELECT users.username, forum_replies.message FROM users,forum_replies WHERE users.id= forum_replies.uid ")or die(mysql_error()); but when i echo the $avatar2 it appears Resource id #3 idk what the problem on my code Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197301 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 but when i echo the $avatar2 it appears Resource id #3 That's actually the correct way your code should be acting. If you look in the manual at mysql_query you will see the method returns a 'resouce' which is what is being outputted. You need to use something like mysql_fetch_assoc to extract the actual data. Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197306 Share on other sites More sharing options...
cruxaders Posted April 5, 2011 Author Share Posted April 5, 2011 if thats the correct code why the image not yet shawn..what will i do to make the image visible Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197310 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 if thats the correct code why the image not yet shawn..what will i do to make the image visible It's not the correct code, but the code you have is acting appropriately. Like I said, you need to use something like mysql_fetch_assoc, pass it in the resource, and extract the information. Click the link to the manual and you will see a variety of examples. This is actually a PHP Coding question, I will move it there. Post the relevant PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197312 Share on other sites More sharing options...
cruxaders Posted April 5, 2011 Author Share Posted April 5, 2011 this the other code with fetch $avatar2 = mysql_query("SELECT users.username, forum_replies.message FROM users,forum_replies WHERE users.id= forum_replies.uid ")or die(mysql_error()); $row3 = mysql_fetch_assoc($avatar2); $location2 = $row4['imagelocation']; <table width=\"100\" border=\"0\" align=\"center\"> <tr> <td><img src =\"$location2\" width=\"100\" hieght=\"100\"></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197314 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 In your query you only SELECT "users.username" & "forum_replies.message", so that's all you can access. I don't see where you're echoing out $avatar2. The $location2 looks correct, but I see where the query or code for that is. Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197323 Share on other sites More sharing options...
cruxaders Posted April 5, 2011 Author Share Posted April 5, 2011 $avatar2 = mysql_query("SELECT users.imagelocation FROM users , forum_replies WHERE users.id=forum_replies.uid ")or die(mysql_error()); $row4 = mysql_fetch_assoc($avatar); $location2 = $row4['imagelocation']; <table width=\"100\" border=\"0\" align=\"center\"> <tr> <td><img src =\"$location2\" width=\"100\" hieght=\"100\"></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197325 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 These lines should be: $row4 = mysql_fetch_assoc($avatar2); $location2 = $row4['users.imagelocation']; Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197328 Share on other sites More sharing options...
cruxaders Posted April 5, 2011 Author Share Posted April 5, 2011 still the image ddnt appear Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197332 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 Output $location2 and see if the image resides in that directory. Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197334 Share on other sites More sharing options...
cruxaders Posted April 5, 2011 Author Share Posted April 5, 2011 ill already figure out the image... tnx for the help and time Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197338 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 ill already figure out the image... Good. tnx for the help and time Sure, np. Quote Link to comment https://forums.phpfreaks.com/topic/232774-can-some-please-check-my-code-if-what-is-wrong/#findComment-1197355 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.