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…


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

  <?php print"$sitetitle"; ?>


<< Back to Directory

<?php if ($enablecode == "1") { echo <<<TEXT TEXT; } ?>
Your name:
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);
flock($fp, LOCK_EX);
fwrite($fp, $tmp. “\n”);
flock($fp, LOCK_UN);

//=== Function below gets specified number of lines and returns an array
function get($start, $end){
global $gbfile;
flock($fp, LOCK_SH);
while($i<$start && !feof($fp)) {
while($i<=$end && !feof($fp)) {
if ($tmp) { array_push($records, $tmp); }

       flock($fp, LOCK_UN); 


//======================Listing part
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"; ?>


and the error message ! -->

and the layout of the database (lol… text file) – >


What error are you getting?

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

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 -
And also the script zipped… Here …

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