Panther and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

hammer32
Forum Newbie
Posts: 3
Joined: Tue Nov 11, 2003 11:32 am

Post by hammer32 »

Weirdan,

I tried modifying the line, and it kind of works, after loading the initial image at:

http://192.168.1.100/~hammer32/images/p ... eshow1.php

it keeps reloading the same one, after the refresh time, over and over at:

http://192.168.1.100/~hammer32/images/p ... hp?index=1

The index number doesn't seem to want to increment.

Thanks!

-Sean
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Paddy, you are completely wrong. Read some manuals. Try to use this html:

Code: Select all

<form action="something.php" method="GET">
  <input type="text" name="some_text" value="something">
  <input type=submit>
</form>
It works. Paddy, read some good book on html. Visit the http://w3c.org/
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

hammer32 wrote:Weirdan,

I tried modifying the line, and it kind of works, after loading the initial image at:

http://192.168.1.100/~hammer32/images/p ... eshow1.php

it keeps reloading the same one, after the refresh time, over and over at:

http://192.168.1.100/~hammer32/images/p ... hp?index=1

The index number doesn't seem to want to increment.

Thanks!

-Sean
Look at this code:

Code: Select all

//..............skipped...............
# Which image to display? 
# if no index specified, default to first page 
if ($index == "") { 
$index = 0; 
} elseif ($index >= count($fileArray)) { 
$index = 0; # loop back to beginning 
}
//............skipped............
As we already know you have register_globals turned off. So you need to rewrite it as follows:

Code: Select all

//..............skipped...............
# Which image to display? 
# if no index specified, default to first page 
$index=@$_GET['index']; //use index from $_GET array
if ($index == "") { 
     $index = 0; 
} elseif ($index >= count($fileArray)) { 
     $index = 0; # loop back to beginning 
}
//............skipped............
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Weirdan wrote:Paddy, you are completely wrong. Read some manuals. Try to use this html:

Code: Select all

<form action="something.php" method="GET">
  <input type="text" name="some_text" value="something">
  <input type=submit>
</form>
It works. Paddy, read some good book on html. Visit the http://w3c.org/
Ah, didn't realise you could put get there. I use get when I throw something into the URL. Can I ask why you would use get?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Paddy wrote: Can I ask why you would use get?
I use get method where it's appropriate (i.e. when requests are idempotent as says RFC2616) And I use forms where I want to give the user ability to construct the request visually. Look at the google.com. They use the GET method for their search form because the request doesn't change the resourse (database in this case). It just retrieves, GETs information from it.
hammer32
Forum Newbie
Posts: 3
Joined: Tue Nov 11, 2003 11:32 am

Post by hammer32 »

Weirdan wrote: As we already know you have register_globals turned off. So you need to rewrite it as follows:

Code: Select all

//..............skipped...............
# Which image to display? 
# if no index specified, default to first page 
$index=@$_GET['index']; //use index from $_GET array
if ($index == "") { 
     $index = 0; 
} elseif ($index >= count($fileArray)) { 
     $index = 0; # loop back to beginning 
}
//............skipped............
I entered that code, but I get an error "Parse error: parse error in /Users/hammer32/Sites/images/pictures/slideshow1.php on line 84

Code: Select all

77   # Read in the list of filenames that have any of the 
78   # accepted extensions
79   $handle=opendir(getcwd());
80   while (false !== ($file = readdir($handle))) {
81       # get the file extension
82       $parts = explode(".", $file);
83       $extension = end($parts);
84   
85       # add file to fileArray if it has a matching extension
86       foreach ($image_extensions as $img_ext) {
87           if (!strcasecmp($extension, $img_ext)) {
88    	       $fileArray[count($fileArray)] = $file;
89   	       break;
90           }
91       }
92   }
93   closedir($handle);
94   sort($fileArray);
Post Reply