register_globals must be turned on on your webserver and off on your local server, you 
are getting the new value for first rec from the GET array registering first_var as a 
global. Same thing for the PHP_SELF error.

So change this you need to get the value of $first_var like 
$first_var=$_GET['first_var'] and $PHP_SELF should be $_SERVER['PHP_SELF']

its much better to rewrite your code so you dont need the register_globals to be on as 
it'll cause you a lot of problems!

hope this helps

-----Original Message-----
From: Ahmed Abdelaliem [mailto:[EMAIL PROTECTED]
Sent: 03 June 2003 16:21
Subject: [PHP-DB] problem with undefined variable

hi again,
i use php/mysql with ISS server on windows xp professional
i have a script that works well on the web to view only 50 records per page, 
but when i use it on my local server i get this error in the page and it 
views the same 1st 50 records
the message in the page is "Notice: Undefined variable: first_rec in 
c:\inetpub\wwwroot\egycds\newpcgames.php on line 124"
and "Notice: Undefined variable: PHP_SELF in 
c:\inetpub\wwwroot\egycds\newpcgames.php on line 183

here is the code i am using
can anyone help me please?

@ $db = mysql_connect("localhost");
$query = "SELECT gameid FROM newpcgames";
$result= mysql_query($query);
$num_recs = mysql_num_rows($result);
$first_rec = ($first_rec) ? $first_rec : 0; //if rec is passed in, use it,
$max_rec = 50;

$test_tr = mysql_query("select * from newpcgames order by gameid desc LIMIT 
while($record = mysql_fetch_array($test_tr))

    echo "
                                <TR onmouseover=\"this.bgColor='000000'\" 
onmouseout=\"this.bgColor='475674'\" bgColor=#475674>

                                <TD width=75>
                                <DIV align=center><FONT
                                echo stripslashes($record['date']) ;
                                echo "</FONT></DIV></TD>
                                <TD width=90>
                                <DIV align=left><FONT color=white>";
                                echo stripslashes($record['type']) ;
                                echo "</FONT></DIV></TD>
                                echo stripslashes($record['link']);
                                echo "\" target=_new2>";
                                echo stripslashes($record['name']);
                                echo "</A>&nbsp;&nbsp;</strong></FONT></TD>

<TD width=50>
                                <DIV align=left><FONT color=#ffffff>";
                                echo stripslashes($record['cds']);
                                echo "</FONT></DIV></TD> <TD width=80>
                                <DIV align=center><FONT color=#ffffff>";
                                echo stripslashes($record['rate']);
                                echo "</FONT></DIV></TD>

<TD width=70>
                                <DIV align=left><FONT color=#ffffff><A
                                echo "\">";
                                echo stripslashes($record['downloader']);
                                echo "</A></FONT></DIV></TD>
                                <TD align=middle vAlign=center 

                                 echo "</TBODY></TABLE><br><br><br>";
                               $next = $first_rec+50;
        $this_rec = $next; //same record number as current, except 1-based

if ($this_rec < $num_recs)
    echo "<div align=center><font color=orange size=2><strong><a 
<<<< Previuos </a></strong></font>";
    echo "<div align=center>";

echo "<font color=orange size=2><strong>&nbsp; &nbsp; Showing $this_rec of 
$num_recs &nbsp; &nbsp; </strong></font></a>";

        if ($prev_rec >= 0) //if record is 1, don't show the previous link
        echo "<font color=orange size=2><strong><a href='$PHP_SELF?first_rec= 
$prev_rec'> Next >>>> </a>";


Tired of spam? Get advanced junk mail protection with MSN 8.

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to