Jump to content

It just quit working


CouchMaster

Recommended Posts

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>";
?>
Link to comment
Share on other sites

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?????????????

Link to comment
Share on other sites

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 [b][nobbc][code][/code][/nobbc][/b] 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):
[code]  <?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>";
?>[/code]

Ken
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.