Closed Thread Icon

Topic awaiting preservation: PHP and images (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12306" title="Pages that link to Topic awaiting preservation: PHP and images (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP and images <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 07-11-2002 16:00

I was reading WarMage's tutorial at Gurus' and was wondering if that could be used to display images as well.

I have tried it and it wouldn't show the images. I have the pages set up just like on the tutorial but like I said, it won't show the pictures. Is there something I missed. I read through the PHP manual on images but didn't really find anything that helped.

Can someone point me in the right direction?

Thanks in advance.

Later,
C:\


~Binary is best~

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 07-11-2002 19:33

What is it exactly that you are trying to do?

-Butcher-

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 07-11-2002 20:00

Here is what I have:

*index.php
In this page I have the PHP code just like in WarMage's tut. So it is linking to the different pages according the link. So the link "page1" will show page one that has an image in it.

*page1.html
This page has nothing but a table with an image.
i.e. <table><tr><td><img></td></tr></table>

*page2.html
Same as page 1

All I am doing is what the tutorial says. It works with using plain text, but as soon as I change the text to an image, it doesn't display the image, just the red X.

I would upload the page, but I am having problems with that server. Sorry.

Later,
C:\


~Binary is best~

kuckus
Bipolar (III) Inmate

From: Berlin (almost)
Insane since: Dec 2001

posted posted 07-11-2002 20:20

Have you already tried to put the whole <img ...> tag into the variable, like:

<?
if ($link == page2){
$page="<img src='image1.jpg' ...>";
}
elseif($link == page3){
$page="<img src='image2.jpg' ...>";
}
else{
$page="<img src='image1.jpg' ...>";
}
?>

(HTML code goes here)

<? echo($page); ?>


Or if that doesn't help, could you post the code of your current index.php?

kuckus (cell #282)

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-11-2002 20:54

Hmmm - try this:

<?php
if ((!$page) &#0124; &#0124; ($page < 1) &#0124; &#0124; ($page > 3)){ // some basic error checking
$page = 1;
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="maincss.css">
<title> index.php </title>
</head>
<body bgcolor="#999999">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="3"><h1>The Template (index.html)</h1></td>
</tr>
<tr>
<td align="center" valign="top"><a href="index.php?page=1"> Page 1 </a></td>
<td align="center" valign="top"><a href="index.php?page=2"> Page 2 </a></td>
<td align="center" valign="top"><a href="index.php?page=3"> Page 3 </a></td>
</tr>
</table>
<?php
include("pages/" . $page . ".php");
?>

<?php
print("<br /><br /><img src=\"images/" . $page . ".gif\" width=\"250\" height=\"250\" border=\"0\" alt=\"\" />");
?>

</body>
</html>

What this does is use just a number (in this case, 1-3), as a variable, instead of something like "page1". I find this way is a little easier, since you can do math calculations and stuff a little easier.

My code listed here includes both another page, and an image to show that it's very simple. See a working copy at http://development.runningwolf.com/code/php/includes/index.php

I hope this helps.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-11-2002 21:30

First right-click on the broken image and see what the path is make sure that matches where the image is on the server

ONe thing about this, the path to the image is not the path from the included file. It's from the page that calls the included file.



.:[ Never resist a perfect moment ]:.

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 07-11-2002 22:40

Pugzly,

I think that your code is exactly what I was looking for. Your demo is almost exactly what I was going to do. I am VERY new to PHP, so a lot of it is a little confusing.

Thanks for all the help, I will give it a go tonight.

Later,
C:\


~Binary is best~

« BackwardsOnwards »

Show Forum Drop Down Menu