Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
outputing images from a php script,help.

Posted by izrafel (izrafel), 14 September 2005
Why cant i output images from a php script when i use
Code:
require_once, require or include
for example include'output_pic.php';

when i run the script directly there is no problem, but if i want to put it on a web page it doesnt want to output the pictures. PLS HELP.

Posted by admin (Graham Ellis), 14 September 2005
Without seeing a little more code, I don't know.  I guess that you might not have called the header function in your PHP so set the header type, or you may have output extra text / information outside the <?php to ?> tags.

Suggestions to fix:

a) check the things I suggest above

if that doesn't sort it ...

b) Have a look at our working image example in the solution centre and see if it gives you a clue with anything we've done differently there.

Failing that ....

c) Post up a little more code, and tell us HOW it fails - a little more details about what you actually see.

Posted by izrafel (izrafel), 14 September 2005
on 09/14/05 at 21:45:21, Graham Ellis wrote:
Without seeing a little more code, I don't know.  I guess that you might not have called the header function in your PHP so set the header type, or you may have output extra text / information outside the <?php to ?> tags.

Suggestions to fix:

a) check the things I suggest above

if that doesn't sort it ...

b) Have a look at our working image example in the solution centre and see if it gives you a clue with anything we've done differently there.

Failing that ....

c) Post up a little more code, and tell us HOW it fails - a little more details about what you actually see.


here is some more code, and for the error is the normal thing that the browser shows when it cant show the image that should be on its place.
Code:
while ($row = $connector->fetchArray($result)){

 echo'<img src="<img src="../images/LanPortal/Graphics/arrow.gif">';
   echo $row['title'];
   echo '</a><br>';

}


Posted by admin (Graham Ellis), 15 September 2005
I notice you're using a relative path to the image, also that you noted in your first post that the script works if you don't bring in this part with an include.

When you include or require a file from a different directory in PHP, all relative paths mentioned stay relative to the paths of the original file brought in; this applies to both server side references and - in you example - images, style sheets, etc that are reference client (browser) side.

In other words, you tell us that your code works with the source in
  /some/path/script.php
which places the image in
  /some/images/LanPortal/Graphics/arrow.gif

If you run your script via an include from
  /a/very/different/place
then it will be looking for the image in
  /a/very/different/images/LanPortal/Graphics/arrow.gif
and (since it's not there) it will fail ...

Solution - place the image on a path from where it can be found now that the rules of how it works are highlighted above.

Posted by izrafel (izrafel), 15 September 2005
on 09/15/05 at 05:27:52, Graham Ellis wrote:
I notice you're using a relative path to the image, also that you noted in your first post that the script works if you don't bring in this part with an include.

When you include or require a file from a different directory in PHP, all relative paths mentioned stay relative to the paths of the original file brought in; this applies to both server side references and - in you example - images, style sheets, etc that are reference client (browser) side.

In other words, you tell us that your code works with the source in
  /some/path/script.php
which places the image in
  /some/images/LanPortal/Graphics/arrow.gif

If you run your script via an include from
  /a/very/different/place
then it will be looking for the image in
  /a/very/different/images/LanPortal/Graphics/arrow.gif
and (since it's not there) it will fail ...

Solution - place the image on a path from where it can be found now that the rules of how it works are highlighted above.

10x man you are a life saver. It worked. The problem was realy in the links.




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho