I have a index.php that works just fine on my localhost, but when i ftp it onto my web server and go to it, it doesn't work. my web host has assured me that my site is php capable. when i look at the source that is produced, it seems to stop at the php tag and do nothing from there. any suggestions??

I came across this thread (http://www.phpbuilder.com/board/showthread.php?t=10334066) but it didn't help any.

    2 things.

    1 - create a new file called info.php. the copy and paste the following code.

    <?php 
    phpinfo(); 
    ?>

    now upload the file to your server and open it in your browser. one of 2 things will happen. you will either:
    a - get the php information for the webserver on which the script was run. or
    b - you will see the code <?php phpinfo(); ?>.
    if b is the case then your webhost is lying to you or has misconfigured something.
    if you get the php info then the problem is with your code.
    check first the version of php running against that on your local host. some syntax changes over different versions and it may just be a minor infraction.

    2 - if its not too much of a large file paste the code here and we can have a look

      the code is for a comic strip site. here's the code. it's fairly simple. just take in the date and display that date's closet comic strip. every strip's date is under the format "yyyymmdd". the first chunk of php, displays the date. the other gets the strip's image and formats links to the previous and next strip. my site gets to the first "<?php" and stops. it doesn't seem to do nething.

      <?php 
      $dir    = "strips/";
      $files = scandir($dir);
      
      $d = $_GET{'d'};
      if (isset($d)) {
      	$date = $d;
      	if ($date < 20061106) {
      		$date = 20061106;
      	}
      }
      else {
       	$date = date("Ymd");
      }
      $currentFile = "$date" . '.jpg';
      
      while (in_array($currentFile, $files) == false & $date > 20061106) {
      	$date--;
      	$currentFile = "$date" . '.jpg';
      }
      
      $a = strtotime($date);
      $x = getdate($a);
      $m = $x[month];
      $d = $x[mday];
      $y = $x[year];
      
      echo "Date: $m $d, $y" . "<br />\n";
      echo "Notes: ";
      
      ?>
      <?php 
      $currentFile = "strips/" . "$currentFile";
      echo "<img src='$currentFile' alt='$m $d, $y' width='800' border='0' />" . "\n" . "\n";
      
      echo "<p class='stripnav'>";
      
      
      $prev = $date;
      $prevFile = $currentFile;
      
       if ($date > 20061106) {
      	while (in_array($prevFile, $files) == false & $prev > 20061106) {
      		$prev--;
      		$prevFile = "$prev" . '.jpg';
      	}
      	echo "<a href='index.php?d=$prev' class='stripnav'>Prev</a> | ";
      }
      
      echo "<a href='index.php' class='stripnav'>Current</a>";
      
      $end = count($files) - 1;
      $next = $date + 1;
      $nextFile = "$next" . '.jpg';
      $currentFile = trim($currentFile, "strips/");
      
      if ($currentFile != $files[$end]) {
      	while (in_array($nextFile, $files) == false) {
      		$next++;
      		$nextFile = "$next" . '.jpg';
      	}
      	echo " | <a href='index.php?d=$next' class='stripnav'>Next</a>";
      }
      
      
      echo "</p>";
      ?>

      [/SIZE]

        Is display_errors set to On and error_reporting set to E_ALL ? If not, make the necessary changes ([man]ini_set/man at the top of your script, if nothing else) and let us know if any errors/warnings/notices appear.

          i ran the phpinfo script and noticed that my server is using "PHP Version 4.4.1" while my local host is running "PHP Version 5.2.0".

          But let me further explain what's happening though. It doesn't seem to be even running the php. An outline of my document looks like this:

          beginning html
          1st php block
          mid html
          2nd php block
          ending html

          when accessed, it reads the beginning html and stops. nothing is in the source file after that. it's a sudden stop. is that due to the difference in php versions?

          also i added this to the top of the first php block and nothing changed:

          ini_set('display_errors', 'On');  
          ini_set('error_reporting', 'E_ALL');

          and thanks for the help!!

            post the script and we can take a look
            or at least post the first block of html and the first block of php

              bradgrafelman wrote:

              E_ALL is a constant, not a string.

              yea, that makes a huge dif. here's the error i'm getting.

              Fatal error: Call to undefined function: scandir() in 
              /services/webpages/h/a/mysite.com/public/index.php on line 27

              is scandir() not in 4.4? if not, what could i use?

                According to this, a PHP 4 alternative to scandir() is:

                <?php
                $dir = "/tmp";
                $dh  = opendir($dir);
                while (false !== ($filename = readdir($dh))) {
                   $files[] = $filename;
                }
                ?>

                [/SIZE]

                I'm a little confuses as to what $filename is. Any help?

                And if a mod or somebody could rename this thread to "A PHP 4 alternative to scandir()" that might help the thread out a bit since I now know what my problem is. Thanks.

                  jaysscholar wrote:

                  I'm a little confuses as to what $filename is. Any help?

                  It's a variable used in the loop... temporarily holds an item from [man]readdir/man until it's added into the $files array. Think of it as a transporting variable - just used to transport the value taken from readdir() into the $files array.

                  jaysscholar wrote:

                  And if a mod or somebody could rename this thread to "A PHP 4 alternative to scandir()" that might help

                  shrug Okay.

                  EDIT: Also, for easier use, you can always make it a function...

                  if(!function_exists('scandir')) { // in case this script gets ported to PHP5, let's not break it
                  	function scandir($dir) {
                  		$files = array(); // added to initialize variable
                  		$dh = opendir($dir) or return FALSE; // added some error-checking
                  		while(false !== ($filename = readdir($dh))) {
                  			if($filename == '.' || $filename == '..')
                  				continue; // no need to get the . or .. references, right?
                  			else
                  				$files[] = $filename;
                  		}
                  		return $files;
                  	}
                  }

                    well, I'm going to stick with opendir() since it seems to work in both 4 and 5. Thanks for the help.

                      Write a Reply...