Jump to content

No image result with image tag


MGLP

Recommended Posts

This might not be an HTML problem but can anyone tell me why I get a little black square with a white X for

[<img src=$Row[25]  height=\"325\" width=\"380\">]?

My image files are jpg and I have no problem when I open them directly using MS Picture Manager or anything else.

Thank you

Link to comment
Share on other sites

If that's a PHP string, you should wrap the $Row[25] in curly braces ( <img src={$Row[25]}  height=\"325\" width=\"380\">  ), otherwise it's just going to print the string "Array". PHP variables are case-sensitive, so make sure that the variable's name is $Row and not $row.

 

 

Link to comment
Share on other sites

Sorry.  I was probably not clear and my apologies for the error in the code I posted.

My code is actually:

[<img src=\"$Row[28]\" height=\"271\" width=\"380\">]    

My "$Rows" comes from my code after getting a record from my database:   [$Row = mysql_fetch_row($Results);] 

$Row[28] contains the file name/reference.  It's not a problem.

It works fine for many of the image files (all JPG) I use in my testing.  But some of them show up as that little black box with a white X in it.  Yet when I open these files directly with MS Picture Manager or other software, there's no problem.

Something else has come up.  Some of my images come out sleeping even if they have been saved standing (I hope I'm clear on that).

 

 

 

Link to comment
Share on other sites

You should check the source code of the generated page to see what URL shows up in the src attribute of the image. Like I said before, wrap the variable in curly braces to make sure it's interpreted correctly by PHP.

Link to comment
Share on other sites

I tried what you said but when I put the {}, I ended up with the little black square with the white X for all of my images.

Re "checking the source code that is generated" I don't understand or don't know how to do that.

All I know is my source code, I.e., my PHP file.  

I've added a print command to print $Row[25] (which is the file name of the image) before the "img" tag is executed and the name is quite correct.  The file extension is not present but I don't think that matters (It works for other image files).

 

Link to comment
Share on other sites

The file extension needs to be present for an image to show.

As for viewing the source code, right-click on your web page and select "View Source" from the context menu. The source code that the browser sees is not the same as the source code that's on your server.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...