Smokey AU Posted February 10, 2009 Share Posted February 10, 2009 Hi There, I am a newbie to PHP and this forum as I am in need of some desperate help. I implemented a guestbook on a clients site, with very little knowledge, but since the client wanted the hosting moved and now the guestbook is fried. The previous server was running PHP v4.3.2-43.ent and the new one 5.2.6. I have no idea if that makes any difference, but something on this new server is killing my code. Basically the GB calls a comments dat file and outputs it, but for some reason this file cannot be found. I know it must be something to do with the directories, but in all my debugging i cannot find the solution. <? $siteRoot=getenv("DOCUMENT_ROOT")."/"; $gbRoot = $siteRoot."__framework/_guest-book/comments/"; $data_file = $gbRoot."comments.dat"; $do = isset($_REQUEST['do']) ? trim($_REQUEST['do']) : ""; $id = isset($_GET['id']) ? trim($_GET['id']) : ""; $page = isset($_GET['page']) ? $_GET['page'] : 1; $self = $_SERVER['PHP_SELF']; if (!file_exists($data_file)) { echo "<b>Error !!</b> Can't find data file : $data_file.<br />"; exit; } else { if ($max_record_in_data_file != "0") { $f = file($data_file); rsort($f); $j = count($f); if ($j > $max_record_in_data_file) { $rf = fopen($data_file,"w"); if (strtoupper($os) == "UNIX") { if (flock($rf,LOCK_EX)) { for ($i=0; $i<$max_record_in_data_file; $i++) { fwrite($rf,$f[$i]); } flock($rf,LOCK_UN); } } else { for ($i=0; $i<$max_record_in_data_file; $i++) { fwrite($rf,$f[$i]); } } fclose($rf); } } } $newline = (strtoupper($os) == "WIN") ? "\r\n" : "\n"; switch ($do) { case "": $record = file($data_file); rsort($record); $jmlrec = count($record); ?> This is what is output. Error !! Can't find data file : $data_file. "; exit; } else { if ($max_record_in_data_file != "0") { $f = file($data_file); rsort($f); $j = count($f); if ($j > $max_record_in_data_file) { $rf = fopen($data_file,"w"); if (strtoupper($os) == "UNIX") { if (flock($rf,LOCK_EX)) { for ($i=0; $i<$max_record_in_data_file; $i++) { fwrite($rf,$f[$i]); } flock($rf,LOCK_UN); } } else { for ($i=0; $i<$max_record_in_data_file; $i++) { fwrite($rf,$f[$i]); } } fclose($rf); } } } $newline = (strtoupper($os) == "WIN") ? "\r\n" : "\n"; switch ($do) { case "": $record = file($data_file); rsort($record); $jmlrec = count($record); ?> '; } $w = 0; //--Color for ($i=0; $i<$max_entry_per_page; $i++) { $nomrec++; $no++; //$no--; $recno = $nomrec-1; if (isset($record[$recno])) { $row = explode("|~|",$record[$recno]); if ($w==0) { $warna = $table_content_1a; $warna2 = $table_content_1b; $w=1; } else { $warna = $table_content_2a; $warna2 = $table_content_2b; $w=0; } echo "'; echo ""; } //--end if } //--end for echo "'; ?> Any help would be much appreciated. If you need more info please let me know. Link to comment https://forums.phpfreaks.com/topic/144573-solved-newbie-help-php-guestbook-nuked/ Share on other sites More sharing options...
Smokey AU Posted February 10, 2009 Author Share Posted February 10, 2009 Silly me. I rolled back to PHP v4 and all is well. Panic now over, thanks for looking. Link to comment https://forums.phpfreaks.com/topic/144573-solved-newbie-help-php-guestbook-nuked/#findComment-758671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.