weird..

[php]echo “<img src=‘img/assets/’” . $myC->body . “”;[/php]

In my mysql table. body is set to “myavatar.png”

the code should display a image, but it doesnt work.

Also
[php]$MyCharacter = $db->query(“SELECT * FROM users WHERE Username=’$User’”);
$myC = $MyCharacter->fetch_object();[/php]

You’re missing the closing > for the img tag.
[php]echo “<img src=‘img/assets/’” . $myC->body . “”>;[/php]

Thanks again, fastsol :slight_smile: You seem to be the most active person on this forum (no offence to the others)

No problem, I’m just bored most of the time so I browse the forums a lot.

http://img829.imageshack.us/img829/364/7wnp.png

It seems like cant resolve the path to the image.

I have the image name in my mysql table.

[php]echo “<img src=‘img/assets/’” . $myC->body . “”>;[/php]

[php]$myC->body [/php] is myavatar.png

Sorry missed the fact that the actual image naem is outside the quotes for the src attribute.
[php]echo ‘’;[/php]
I also changed around the quotes for the whole thing. Using single quotes is a better idea when making html elements in php cause html likes “double” quotes best, so using ‘single’ quotes around the whole string is best.

still doesnt work :o

here is the page:

[php]<?php

include ‘header.php’;

if(!$loggedIn) {
echo "

Play free games created by our community
Customize your avatar with the variety of items in our shop
Share the games you create with others and earn bux


Register | Login
"; } elseif($loggedIn) { echo "

Welcome, $loggedIn!



Throughout your stay on the website, this page will be your \"home\".
Here you can manage the various aspects of your avatar.

"; echo '';

}

[/php]

header.php

[php]

MadBlockz | Under Development
Site under development, when I finish I will move it to a new domain
<?php error_reporting(E_ALL & E_STRICT); session_id(); session_start(); ob_start(); $loggedIn = $_SESSION['Username']; $Password = $_SESSION['Password']; $db = new mysqli("localhost", "root", "", "madblockz"); if ($db->connect_errno) { echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error; } $currentTime = time(); $MyCharacter = $db->query("SELECT * FROM users WHERE Username='$User'"); $myC = $MyCharacter->fetch_object(); $rank = $myC->rank; $body = $myC->body; // IF THERES NO RANK SET RANK TO MEMBER if($rank=='') { $db->query("UPDATE users SET rank='Member' WHERE Username='$User'"); } if($myC->body=='') { $db->query("UPDATE users SET body='myavatar.png'"); }

?>

[/php]

Well then you need to start doing some basic diagnostic. View the page source and see what it says the image path is in the img tag. Are you sure that $myC->body has a value?

I sourced it.
It seems like it doesnt read it from the mysql database

This is what I found when I sourced:

<div id='homeavatar'><img src="img/assets/ "></div>

This is how my MySQL table looks like:
Direct link to picture: http://img694.imageshack.us/img694/7264/pqo.png

If it’s not getting it from the database it’s likely a query issue. Post the query pwez.

wait, I didn’t see that post.
one sec.

[php]$MyCharacter = $db->query(“SELECT * FROM users WHERE Username=’$User’”);
$myC = $MyCharacter->fetch_object();[/php]

  1. Are you sure $db is active?
  2. What does $MyCharacter->fetch_array() return? Use print_r to see.

Im so stupid, there was a error in my query

I forgot I changed $User to $loggedIn

Thank you guys

Sponsor our Newsletter | Privacy Policy | Terms of Service