lamboman Posted May 27, 2011 Share Posted May 27, 2011 I am Pretty new to PHP and I know this is something I have wrong with the way it is laid out. Any help would be appriciated. I will be adding more images later (an array) but this is the start but it wont display the image <?php $bottle[0]='<img src="images/bottlesandcaps/diamondbottles/smalldiamonddarkblue.gif'">'; $bottle[1]='<img src="images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif'">'; echo $bottle[0]; ?> Thanks in advance Quote Link to comment Share on other sites More sharing options...
freelance84 Posted May 27, 2011 Share Posted May 27, 2011 error Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 27, 2011 Share Posted May 27, 2011 maybe your src is wrong. I bet you want / before images... Quote Link to comment Share on other sites More sharing options...
gristoi Posted May 27, 2011 Share Posted May 27, 2011 1. does the image exist on the server / your pc. 2. is the images folder sitting in the same directory as this test script. 3. you could try and see if the file exists: if (file_exists("images/bottlesandcaps/diamondbottles/smalldiamonddarkblue.gif")) { echo"image exists!"; } else { echo"image does not exist!"; } Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted May 27, 2011 Share Posted May 27, 2011 just before we get crap loads of if's your syntax is wrong $bottle[1]='<img src="images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif'">'; should be $bottle[1]='<img src="images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif">'; in other words, the last part of your string has a ' to many (should be ">'; and not '">'; ) besides that you are indeed missing an alt= " " attribute as said above, but that was not breaking your syntax. P.s. a small hint, count the " and ' they should be even numbers (they come in pairs ) Quote Link to comment Share on other sites More sharing options...
gristoi Posted May 27, 2011 Share Posted May 27, 2011 well spotted lol Quote Link to comment Share on other sites More sharing options...
netbookpros Posted May 27, 2011 Share Posted May 27, 2011 You've not escaped the quotes in your strings? And there was an extra quote in the first string. try this: <?php $bottle[0]="<img src=\"images/bottlesandcaps/diamondbottles/smalldiamonddarkblue.gif\">"; $bottle[1]="<img src=\"images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif\">"; echo $bottle[0]; ?> Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted May 27, 2011 Share Posted May 27, 2011 That should work. Your single and double quotes may be incorrect? Try this: <?php $bottle[0]="<img src='images/bottlesandcaps/diamondbottles/smalldiamonddarkblue.gif'>"; $bottle[1]="<img src='images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif'>"; echo $bottle[0]; ?> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 27, 2011 Share Posted May 27, 2011 just before we get crap loads of if's your syntax is wrong $bottle[1]='<img src="images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif'">'; should be $bottle[1]='<img src="images/bottlesandcaps/diamondbottles/smalldiamonddarkclear.gif">'; in other words, the last part of your string has a ' to many (should be ">'; and not '">'; ) besides that you are indeed missing an alt= " " attribute as said above, but that was not breaking your syntax. I did not see that that is one reason we use code and/or php tags Quote Link to comment Share on other sites More sharing options...
lamboman Posted May 27, 2011 Author Share Posted May 27, 2011 Thanks dougjohnson, that made it work. Quote Link to comment Share on other sites More sharing options...
gristoi Posted May 27, 2011 Share Posted May 27, 2011 damn extra speech mark. gets me every time. Quote Link to comment 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.