CouchMaster Posted October 28, 2006 Share Posted October 28, 2006 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 https://forums.phpfreaks.com/topic/25393-it-just-quit-working/ Share on other sites More sharing options...
Psycho Posted October 28, 2006 Share Posted October 28, 2006 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. Link to comment https://forums.phpfreaks.com/topic/25393-it-just-quit-working/#findComment-115797 Share on other sites More sharing options...
CouchMaster Posted October 28, 2006 Author Share Posted October 28, 2006 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 https://forums.phpfreaks.com/topic/25393-it-just-quit-working/#findComment-115807 Share on other sites More sharing options...
kenrbnsn Posted October 28, 2006 Share Posted October 28, 2006 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.somethingWhen 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 https://forums.phpfreaks.com/topic/25393-it-just-quit-working/#findComment-115818 Share on other sites More sharing options...
CouchMaster Posted October 28, 2006 Author Share Posted October 28, 2006 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 https://forums.phpfreaks.com/topic/25393-it-just-quit-working/#findComment-115829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.