php-windows Digest 9 Sep 2006 15:52:45 -0000 Issue 3034

Topics (messages 27133 through 27138):

Re: Installation problems - Win XP with IIS and MySQ
        27133 by: Alex Turner

Undefined variables
        27134 by: Alf Stockton

Re: [Linux dev] Undefined variables
        27135 by: Hendrik Visage
        27136 by: Stut
        27137 by: Alex Turner

Re: Problem with execution external script
        27138 by: DevPhp

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
zerof wrote:
Bradley Davidson escreveu:
I have tried to follow the instructions to manually install PHP on Windows
XP, using IIS and MySQL.  I have been unable to test if PHP is installed
because when I try to open a PHP file in a browser (either firefox or IE6)
it launches Dreamweaver.

What should I try?
IMHO, forget IIS and strat using Apache.
http://www.educar.pro.br/
-----
zerof
It would seem that IE does not 'think' that your script is dynamic - it is trying to serve it as a static file.

I don't use IIS, we use TAG.net as we have had nothing but pain from IIS :-(

If you are doing simple stuff, Apache on windows is very good.

Best wishes

AJ

--
www.deployview.com
www.nerds-central.com
www.project-network.com

--- End Message ---
--- Begin Message ---
In this little script:-

<?php
#This script has been developped by Nenad Motika [EMAIL PROTECTED]
#Please feel free to use it and to contact me for any reason
session_start();
//read folder
$folder=opendir(".");
while ($file = readdir($folder))
$names[count($names)] = $file;  // <----- Line 8
closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar = $i = 0;
for ($i=0;$names[$i];$i++) {    // <----- Line 14
   $ext=strtolower(substr($names[$i],-4));
   if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png") {
       $names1[$tempvar]=$names[$i];
       $tempvar++;
       }
}
   $Count = $_SESSION['Picture'];
   --$Count;
//        echo 'Count = '.$Count.'  $tempvar = '.$tempvar;
   if ($Count == 0) {
       $Count = $tempvar-1;
       }
   $_SESSION['Picture'] = $Count;
   $slika=$names1[$Count];
//image dimensions
$dimensions = GetImageSize($slika);
if (isset($HTTP_GET_VARS["pic"])){header ("Location: $slika");}
else {echo "<img src=\"$slika\" $dimensions[3]>";}
?>


I keep getting:-

[Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice: Undefined variable: names in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 8, referer: http://localhost/events/rotate.shtml [Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice: Undefined offset: 13 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 14, referer: http://localhost/events/rotate.shtml

Please tell me what evil I have committed to cause this?

--
Regards,
Alf Stockton            www.stockton.co.za

Lay on, MacDuff, and curs'd be him who first cries, "Hold, enough!".
                -- Shakespeare
My email disclaimer is available at www.stockton.co.za/disclaimer.html

--- End Message ---
--- Begin Message ---
On 9/8/06, Alf Stockton <[EMAIL PROTECTED]> wrote:
In this little script:-

<?php
session_start();
//read folder
$folder=opendir(".");
while ($file = readdir($folder))
$names[count($names)] = $file;  // <----- Line 8

Obviously $names won't be defined in the initial state the first time this line
is hit, thus count($names) would/should be undefined...

closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar = $i = 0;

These "shortcircuit" assignments aren't the best of things to do...

for ($i=0;$names[$i];$i++) {    // <----- Line 14

Remember the undefined case up there, there just might not be a
index 0, be rather an index "undefined" ....

Don't we just *love* these interpreted languages and their "funnies" :)

I keep getting:-

[Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice:
Undefined variable: names in C:\\Program Files\\Apache Software
Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 8,
referer: http://localhost/events/rotate.shtml
[Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice:
Undefined offset:  13 in C:\\Program Files\\Apache Software
Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 14,
referer: http://localhost/events/rotate.shtml

Please tell me what evil I have committed to cause this?

--
Regards,
Alf Stockton            www.stockton.co.za

Lay on, MacDuff, and curs'd be him who first cries, "Hold, enough!".
                -- Shakespeare
My email disclaimer is available at www.stockton.co.za/disclaimer.html

---
To unsubscribe: send the line "unsubscribe dev" in the subject of a
mail to [EMAIL PROTECTED] Problems: [EMAIL PROTECTED]
Archives at http://www.linux.org.za/Lists-Archives/




--
Groete in Jesus Christus, ons enigste Verlosser en Saligmaker
Greetings in Jesus Christ, our only Saviour and Salvation.
Hendrik Visage

--- End Message ---
--- Begin Message ---
Hendrik Visage wrote:
<snip useful explanation of what's wrong with no tips on how to do it right>

The rewrite below does not iterate around the array as you were in your for loop, so I'll mention a better way to do that here rather than in the snippet below... foreach - look it up in the PHP manual!

One way to rewrite it would be like this (with comments hopefully explaining what I've changed and why)...

<?php
   session_start();
   $folder = opendir('.');
// No need for a temporary array, check each file as you read it from the directory
   $names = array();
   while ($file = readdir($folder))
   {
if (in_array(strtolower(substr($file, -4)), array('.jpg', '.gif', 'jpeg', '.png')))
       {
// You can append an element to an array like this... no need for an index
           $names[] = $file;
       }
   }

   sort($names);

// Not sure why you're checking a session var here since you've just gone to the trouble of iterating
   // over the files - it's not saving much processing

   // Best practice to always check if a session var exists before using it
   // Avoids unsightly notices
   $Count = (isset($_SESSION['Picture']) ? $_SESSION['Picture'] : 0);
// Really not sure why this is here
   --$Count;
   //        echo 'Count = '.$Count.'  $tempvar = '.$tempvar;

   if ($Count == 0)
   {
       $Count = count($names1)-1;
   }

   $_SESSION['Picture'] = $Count;
   $slika = $names[$Count];
   // image dimensions
   $dimensions = GetImageSize($slika);
   if (isset($HTTP_GET_VARS["pic"]))
   {
// Strictly speaking the URL given in a location header should be absolute
       header ("Location: $slika");
   }
   else
   {
       echo "<img src=\"$slika\" $dimensions[3] />";
   }

--- End Message ---
--- Begin Message --- Foreach is very much better as it does not mean having to traverse the array to find the given value. If you have a long array, you'll find looking up a element by index gets slow.

AJ

Stut wrote:
Hendrik Visage wrote:
<snip useful explanation of what's wrong with no tips on how to do it right>

The rewrite below does not iterate around the array as you were in your for loop, so I'll mention a better way to do that here rather than in the snippet below... foreach - look it up in the PHP manual!

One way to rewrite it would be like this (with comments hopefully explaining what I've changed and why)...

<?php
   session_start();
   $folder = opendir('.');
// No need for a temporary array, check each file as you read it from the directory
   $names = array();
   while ($file = readdir($folder))
   {
if (in_array(strtolower(substr($file, -4)), array('.jpg', '.gif', 'jpeg', '.png')))
       {
// You can append an element to an array like this... no need for an index
           $names[] = $file;
       }
   }

   sort($names);

// Not sure why you're checking a session var here since you've just gone to the trouble of iterating
   // over the files - it's not saving much processing

   // Best practice to always check if a session var exists before using it
   // Avoids unsightly notices
   $Count = (isset($_SESSION['Picture']) ? $_SESSION['Picture'] : 0);
     // Really not sure why this is here
   --$Count;
   //        echo 'Count = '.$Count.'  $tempvar = '.$tempvar;

   if ($Count == 0)
   {
       $Count = count($names1)-1;
   }

   $_SESSION['Picture'] = $Count;
   $slika = $names[$Count];
   // image dimensions
   $dimensions = GetImageSize($slika);
   if (isset($HTTP_GET_VARS["pic"]))
   {
// Strictly speaking the URL given in a location header should be absolute
       header ("Location: $slika");
   }
   else
   {
       echo "<img src=\"$slika\" $dimensions[3] />";
   }


--
www.deployview.com
www.nerds-central.com
www.project-network.com

--- End Message ---
--- Begin Message ---
Hallo,
thanks for reply.

> Also - why double launch?  Why not launch csript directly?

I've tried to launch Cscript directly...but it didn't work,
So I try to launch it in an alternative way, to bypass the permission 
problem.
It's not necessary double launch....

> I guess that your server is running as a user with reduced permissions and 
> thus cannot access the exec.

How can I see which user is? I've full permission for IUSR, IWAM and SYSTEM 
users on php directory,
on root directory and also on system32 directory...in IIS I've read 
permission and allow execution for script and executables...but it doesn't 
still work....
Am I doing something wrong?

I'm still trying to find a solutions...

Please can you help me?
Thanks

--- End Message ---

Reply via email to