Jump to content

Can some please check my code if what is wrong


cruxaders

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

$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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.