[Crying] php output image problem is killing me

Hey, if you can give me url or code in pm. I'll fix this issue for you.
Just some parameters issue tends to be there and because of that image is getting broken.
 
Ok. I used chrome & inspected the element. & the image output is okay

<img src="profile/paul k 23445667788744.jpg" border="0" width="300" height="200">

As, pointed out by tb303 above, my html code doesn't need a slash. Anyways, I took it off & it still didn't work. Image is still broken. I ran a Google search & I'm surprised there was no useful reply even on stackoverflow.....

your image name is paulk23445667788744.jpg but after generating, it is getting parameters as paul k 23445667788744.jpg and because of those spaces you are getting broken image.
 
this line in your code
Code:
<td class=\"stylki go\"><img src='/'". $register["image"] ." border=\"0\" width=\"300\" height=\"200\"

you're not closing the image tag. change it to this
Code:
<td class=\"stylki go\"><img src='/'". $register["image"] ." border=\"0\" width=\"300\" height=\"200\">

you could also do it this way as it makes your code easier to read (for me anyway lol)
Code:
<td class='stylki go'><img src='".$register['image']."' border='0' width='300' height='200'>

also technically by adding a slash to the start of the url you fetch from the DB you make it absolute to root

if your "profile" directory is a sub of where your php is located then you were right with no slash
if profile is found in the www root then you need to add a slash at the start.

Man thanks for ur reply. I tried it & I'm still stuck here. The funny thing is I used same method of outputting image from db on other part of my script.

Could it be db datatype( I used varchar) or encoding (i used latin1)


Oh..…. I'm so crazzzyyy now
 
Thanks, man... I really don't know what u mean. The output code is something like this:

$details = mysql_query("SELECT * FROM master WHERE username='$delle'");
mysql_fetch_array($details);
$out=$details["image"];
echo $out;


N:B==> in db, image is stored like this: " profile/image_name.jpg "

I guess it's relative since it will automatically be appended to browserurl
E.g blackhatworld.com/profile/image_name.jpg

I use this one and everything works lyk a charm :D


$sql = "SELECT * FROM products WHERE id = $id";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';
 
Hey, if you can give me url or code in pm. I'll fix this issue for you.
Just some parameters issue tends to be there and because of that image is getting broken.
It's a really large script. I have about 10000+ lines in this particular php file(which is not too ideal to share). If I give a the section corresponding to the image, I don't know if u will grab the idea cos of so many coinditions preceding the image section that's why I'm skeptical.... Do I still share image section with u? Thanks
 
I use this one and everything works lyk a charm :D


$sql = "SELECT * FROM products WHERE id = $id";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';
Man, oop.... I'm using procedural php. I didn't use base64 when uploading... Will it be a problem using this code?
 
your image name is paulk23445667788744.jpg but after generating, it is getting parameters as paul k 23445667788744.jpg and because of those spaces you are getting broken image.
yea... I think this should be the problem ..... Hoiw do I stop this? Oooo..... I love ur thinking skill
 
Ok. I used chrome & inspected the element. & the image output is okay

<img src="profile/paul k 23445667788744.jpg" border="0" width="300" height="200">

As, pointed out by tb303 above, my html code doesn't need a slash. Anyways, I took it off & it still didn't work. Image is still broken. I ran a Google search & I'm surprised there was no useful reply even on stackoverflow.....

Try adding your absolute URL in your output to see if it works.

It gets really hard to diagnose an issue which shouldn't occur normally, without having seen the page first.
 
yea... I think this should be the problem ..... Hoiw do I stop this? Oooo..... I love ur thinking skill
$new = str_replace(' ', '%20', $your_string);
use this, the issue will get solve :)
 
$new = str_replace(' ', '%20', $your_string);
use this, the issue will get solve :)
Man..... Please, I beg u in the name of God be a little elaborate

$your_sting= what do I put here?

What do I echo as the image output to display image ? $new?

echo $new; ?

Where to put Img src now?
 
Try adding your absolute URL in your output to see if it works.

It gets really hard to diagnose an issue which shouldn't occur normally, without having seen the page first.

I really appreciate ur persistent persistent help. It still didn't work....
 
Man..... Please, I beg u in the name of God be a little elaborate

$your_sting= what do I put here?

What do I echo as the image output to display image ? $new?

echo $new; ?

Where to put Img src now?


Don't beg mate...
We are here to help :)

Code:
echo str_replace(' ', '%20', 'http://domain.com/profile/paul k 23445667788744.jpg');  <-use this one
 
Don't beg mate...
We are here to help :)

Code:
echo str_replace(' ', '%20', 'http://domain.com/profile/paul k 23445667788744.jpg');  <-use this one
Lol.. Yea, help me.

But,
Man, it's not specific to that image. I'm using it for all users..… look at my output code

echo"<img src='" .$profile["pic"]. "' border=\"0\" width=\"300\" height=\"200\">";
 
@soccerlover... It turns out that in my db, the image already contains white space... Why isn't it still outputting? Oh... Will this ever be solved now? & I was happy already
 
@soccerlover... It turns out that in my db, the image already contains white space... Why isn't it still outputting? Oh... Will this ever be solved now? & I was happy already
can you forward your code to me? I'll look at everything and will fix it.
It doesn't seems to be a bigger issue.
 
Going back to your convo with soccerlover, I think he is referring to this:

$profile["pic"] = str_replace(' ', '%20', $profile["pic"]);

Or something along those lines :P Like you're taking that DB variable, and filtering it to replace the spaces with nothing.
 
Going back to your convo with soccerlover, I think he is referring to this:

$profile["pic"] = str_replace(' ', '%20', $profile["pic"]);

Or something along those lines :p Like you're taking that DB variable, and filtering it to replace the spaces with nothing.
Yea.... Thanks. I did it. But, not working ...... Hmmm
 
little confused. can you clarify

profile/paul k 23445667788744.jpg is what is output from your database? So what should the correct filename look like? Full path (excluding domain)

the advice about escaping the whitespace above is probably pointless.
your browser will do this automatically. eg click here

as you say this works on another page but not on this one then that implies its the code thats wrong not how its stored in the db

It does sound like a relative url problem. How does the full path to the jpg compare to the one echo'd from the db?
Test it - Add another line to your code to echo a <a> tag with your db url as the href. Then click it see what you get and how that compares with what it should be.
 
Last edited:
Back
Top