Closed Thread Icon

Preserved Topic: PHP webcomic code help. please. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21226" title="Pages that link to Preserved Topic: PHP webcomic code help. please. (Page 1 of 1)" rel="nofollow" >Preserved Topic: PHP webcomic code help. please. <span class="small">(Page 1 of 1)</span>\

 
No Name Trowa Barton
Obsessive-Compulsive (I) Inmate

From: THE WORLD > DELTA SERVER > MAC ANU
Insane since: Jun 2002

posted posted 07-29-2002 21:51

ok with your guy's help i think its fixed
<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
<?php
/*
This script will be called as Ep.php?comic=0001 where
0001 is the number on the file Ep0001.jpg and so on. To view
the latest comic you would call this script as just Ep.php
*/

$comic = $_GET['comic'];
$file = 'Ep' . $comic . '.jpg';

$path = 'http://nntb.port5.com/Image/'; //the path to your images directory, must have the trailing slash
$latest = 'Ep00002.jpg'; //change the number on this when you make a new comic

if (empty($comic)) {
?>
<img src="<?php echo $path . $latest; ?>" alt="The latest comic">
<?php //
}

else {
if (file_exists($path . $file)) {
?>
<img src="<?php echo $path . $file; ?>" alt="Comic Number <?php echo $comic; ?>">
<?php
}

else {
echo('AAAAAAAAAAAAA what did you do i cant find the ep your looking for???');
}
}
?>
<center>
<a href="Ep.php?comic=00001">First</a>

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 07-29-2002 22:31

This looks like it, in this line he drops out of PHP parsing mode for ease of use, the problem is (and danger of this) is that he doesn't go back into PHP parsing mode
if (empty($comic)) {
?>
<img src="<?php echo $path . $latest; ?>" alt="The latest comic">

<?php // <--- you need this here.
}
else {






.:[ Never resist a perfect moment ]:.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-29-2002 22:51

You also have a syntax error in this line:

$path = //'http://nntb.port5.com/Image/'; the path to your images directory, must have the trailing slash

Notice how you commented variable value (which leaves just "$path =" and that's invalid);

Oh, and one more thing, file_exists() function doesn't work with remote files and therefore will fail in your case (since your files are located on another server)...


No Name Trowa Barton
Obsessive-Compulsive (I) Inmate

From: THE WORLD > DELTA SERVER > MAC ANU
Insane since: Jun 2002

posted posted 07-30-2002 07:56

omg i feal soo stupid
it was the comment :shock:
well i am sure not to do that again, sorry for not seeing that. /*with my background in C++ i should have noticed this problum right away*/ thanks guys for your sugestions ^_^

ok now the only problum is that the first comic link does not seem to work http://nntb.port5.com/Ep.php
click here to see what i mean.

(fixed the url -bit)

[This message has been edited by bitdamaged (edited 07-30-2002).]

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 07-30-2002 18:30

hmm works for me?



.:[ Never resist a perfect moment ]:.

No Name Trowa Barton
Obsessive-Compulsive (I) Inmate

From: THE WORLD > DELTA SERVER > MAC ANU
Insane since: Jun 2002

posted posted 07-30-2002 21:25

When you click on previous comic its supose to load a diffrent comic. there are 2 there, the one it loads is http://nntb.port5.com/Image/Ep00002.jpg when the first comic was http://nntb.port5.com/Image/Ep00001.jpg now does the page load for you or does the link work for you? because the page has no error for me but it does not want to goto any previous comics? some help please.

note i edited the first message so you could see what my php file looks like curently. is there an logic error?

[This message has been edited by No Name Trowa Barton (edited 07-30-2002).]

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 07-30-2002 22:24

Yeah there's a couple of issues with the links.

First if $comic is not set in the url then it's not gettings set to anything period so the
echo $comic - 1 and echo $comic++ are not doing anything.

All the leading 0's are getting wasted as well;

Finally for some interesting reason (and I haven't seen this before) trying to output
echo $count +1 does nothing. So strange;



.:[ Never resist a perfect moment ]:.

No Name Trowa Barton
Obsessive-Compulsive (I) Inmate

From: THE WORLD > DELTA SERVER > MAC ANU
Insane since: Jun 2002

posted posted 07-31-2002 00:28

ha ha ha i kind of fixed it now i just need to know why its not showing comics other then the first!!!!!!

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
<?
/**************************************************************

No Name Trowa Barton
Obsessive-Compulsive (I) Inmate

From: THE WORLD > DELTA SERVER > MAC ANU
Insane since: Jun 2002

posted posted 08-05-2002 20:44

so with the new changes does anyone here have a single idea as to why this is failing? or a link to someone who is god in the PHP world so i could summon his powers upon my script?

[center]
No Name Trowa Barton is an offical Member Of The Society Against The Wussification Of Quatre Raberba Winner
TIME heals all wounds but a CURE 3 works better

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 08-07-2002 07:41

oh I got it. you are confusing your web paths with your filesystem paths.

file_exists looks for file system paths usually something like /usr/web/blah and you are passing in a web paths

instead of
else if (file_exists($path . $file))

try
else if (fopen($path . $file))

anyone know a better way to test for the existance of a remote file?



.:[ Never resist a perfect moment ]:.

« BackwardsOnwards »

Show Forum Drop Down Menu