Jump to content


Photo

It just quit working


  • Please log in to reply
4 replies to this topic

#1 CouchMaster

CouchMaster
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 October 2006 - 12:17 PM

This code was working fine 2 days ago.  It shows a photo with info and a price beneath it.
The photo still shows but the info and price quit showing.  Any ideas what went wrong?

    <?php
    echo "<img class=\"main_img\" src=\"./images4/$_GET[name].jpg\" width=\"575\" height=\"375\" alt=\"$_GET[name]\">";
  echo "</font><p><font color=\"white\"><b>";


$handle = fopen("./images4/$_GET[name].txt", "r");
while (!feof($handle)) {
  $buffer = fgets($handle, 4096);
}
fclose($handle);
$myarray = array(); 
$myarray = explode("|", $buffer);
echo "$myarray[1]<br><br>$myarray[2]<br><br><font color=\"blue\">$myarray[3]</font>";
echo "</b></font></p>";
?>

#2 Psycho

Psycho
  • Moderators
  • Move along, nothing to see here
  • 11,891 posts
  • LocationCanada

Posted 28 October 2006 - 12:49 PM

If the code was working previously, and the code hasn't changesd, then the input file has. Check the input file and for debugging purposes, echo the content of $buffer before splitting it inot an array.
The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#3 CouchMaster

CouchMaster
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 October 2006 - 01:40 PM

Tried the suggestion and - nothing.  It's not opening the txt file, which appears normal.  If I echo $handle I get - Resource id #1 - if that means anything - but nothing on $buffer.
Also the txt file is like this - |name|data|price|
One reason I'm asking is because the other day everything stopped working  I realized I was using $name, and when I changed it to $_GET[name] (something about globals) it started working again.  Now something else went haywire and I'm guessing it a similiar problem but I can't find it in my php book.
Suggestions?????????????



#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 October 2006 - 02:07 PM

Is this on your own machine or a shared hosting machine? If it is on a shared hosting machine, contact the support people and ask them if anything changed in the last few days. You may be surprised. It sounds like they upgraded PHP from v4.something to v5.something

When posting code, please surround your code with the [code][/code] tags. You can edit your post to add them. This will make you code much easier to read.

Here's how I would write your code (this may or may not solve your problem):
  <?php
       echo '<img class="main_img" src="./images4/' . $_GET['name'] . '.jpg" width="575" height="375" alt="' . $_GET['name'] . '">';
       echo '</font><p style="color:white">';  // I am assuming that the background color is not white here...
       $lines = file('./images4/' .$_GET['name'] . '.txt');
       foreach ($lines as $line)
            if (strlen(trim($line)) > 0) $myarray = explode("|", trim($line)));
               echo $myarray[1] . '<br>' . $myarray[2] . '<br><span style="color:blue">' . $myarray[3] . '</span>';
       echo "</p>";
?>

Ken

#5 CouchMaster

CouchMaster
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 October 2006 - 02:32 PM

Ken, your amazing - that actually works, just like it did before!  I will study this carefully, and Thanks a Million.  And I do believe that the two hosting companies that I use are upgrading php - it's just ironic that they are doing the same thing at the same time and it crashed on both on the same day!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users