PHP idiot need help

Hello PHP guru’s !

I’m an html and Wordpress person and don’t know PHP at all. I found this little text flatfile database script that I want to do something with but the listing part does not work !

Listed below is the script… and link image of the error … and link to an image of the database structure…

Any help will be appreciated…
Ta
Sam

[php]

<?php require("../config.php"); if ($enablegzip == "1") { ob_start("ob_gzhandler"); header("Content-Encoding: gzip"); } session_start(); ?>
 

  <?php print"$sitetitle"; ?>

 

LINKS
<< Back to Directory



<?php if ($enablecode == "1") { echo <<<TEXT TEXT; } ?>
Title:
Link:
Description:
Your name:
Email:
Country:
Link Quality: 1 2 3 4 5
Enter this text into this field
 

<? $gbfile='links.txt'; $separator= '|';

//==== This function will add one line to the end of file
function add($str){
global $gbfile;
$tmp = trim($str);
$fp=fopen($gbfile,‘a+’);
flock($fp, LOCK_EX);
fwrite($fp, $tmp. “\n”);
flock($fp, LOCK_UN);
fclose($fp);
}

//=== Function below gets specified number of lines and returns an array
function get($start, $end){
global $gbfile;
$records=array();
$filename=“links.txt”;
$fp=fopen($gbfile,‘r’);
flock($fp, LOCK_SH);
$i=1;
$tmp=TRUE;
while($i<$start && !feof($fp)) {
$tmp=fgets($fp);
$i++;
}
while($i<=$end && !feof($fp)) {
$tmp=trim(fgets($fp));
if ($tmp) { array_push($records, $tmp); }
$i++;
}

       flock($fp, LOCK_UN); 
  fclose($fp); 
  return($records);

}

//======================Listing part
$start=$_GET[‘start’];
$end=$_GET[‘end’];
if (!$end || $start<=0) { $start=1; }
if (!$end) { $end=$linkspage; }
if ($end<$start) { $end=$start+1; }
$show=$end - $start;
//======================Get records from file into array
$records = get($start, $end);
//=======================For each record get each field
foreach ($records as $rec) {
$tmp = explode($separator, $rec);
$title = $tmp[0];
$link = $tmp[1];
$desc = $tmp[2];
$name = $tmp[3];
$email = $tmp[4];
$country = $tmp[5];
$rating = $tmp[6];

//================== Outputting
?>

Title: <?=$title?>
Link: <?=$link?>
Description: <?=$desc?>
Link submitted by <?=$name?> from <?=$country?> Rating

<? } //Pagination if ($start>$show) { $start-=$show; $end-=$show; $start--; $end--; print "
  "; if (count($records)!=0) { $start+=$show*2; $end+=$show*2; $start=$start+2; $end=$end+2; print "
"; $start--; $end--; } else { print "No more records found !"; } } else { $start+=$show; $end+=$show; $start++; $end++; print "
"; $start--; $end--; } ?>
<?php print"$sitefooter"; ?>

[/php]

and the error message ! --> http://gamez.za.org/appsbar.PNG

and the layout of the database (lol… text file) – >http://gamez.za.org/appy.PNG

Hi,

What error are you getting?

Thanks for answering… it is linked to this png file !

http://gamez.za.org/appsbar.PNG

It has got something to do with the pagination between pages of data !

I don’t know much so that all I can answer !

It’s due to a simple error. Change this:

<? } //Pagination

To this:

<?php } //Pagination

The difference? Your host is not set to understand <? as a PHP tag.

hi sebrenauld

Thank you… it is looping through the records but not displaying them now !
Also now has " Notice: Undefined index: start in …"

Thank you for your help !

I have uploaded the newest error message again here - http://gamez.za.org/mobincube.PNG
And also the script zipped… Here … http://gamez.za.org/arts.rar

Thank you

There is one more PHP short-tag you need to change:

<? $gbfile='links.txt'; $separator= '|';

Same as before:

<?php $gbfile='links.txt'; $separator= '|';

Sponsor our Newsletter | Privacy Policy | Terms of Service