[PHP-DB] problem with undefined variable

2003-06-04 Thread Ahmed Abdelaliem
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);
mysql_select_db(egycds);
$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 
$first_rec,
$max_rec);
while($record = mysql_fetch_array($test_tr))
{



   echo 
   TR onmouseover=\this.bgColor='00'\ 
onmouseout=\this.bgColor='475674'\ bgColor=#475674

   TD width=75
   DIV align=centerFONT
   color=#ff;
   echo stripslashes($record['date']) ;
   echo /FONT/DIV/TD
   TD width=90
   DIV align=leftFONT color=white;
   echo stripslashes($record['type']) ;
   echo /FONT/DIV/TD
   TDFONT 
color=#ffstrongnbsp;nbsp;A
   href=\;
   echo stripslashes($record['link']);
   echo \ target=_new2;
   echo stripslashes($record['name']);
   echo /Anbsp;nbsp;/strong/FONT/TD

TD width=50
   DIV align=leftFONT color=#ff;
   echo stripslashes($record['cds']);
   echo /FONT/DIV/TD TD width=80
   DIV align=centerFONT color=#ff;
   echo stripslashes($record['rate']);
   echo /FONT/DIV/TD
TD width=70
   DIV align=leftFONT color=#ffA
   href=\;
   echo 
stripslashes($record['downloaderlink']);
   echo \;
   echo stripslashes($record['downloader']);
   echo /A/FONT/DIV/TD
   TD align=middle vAlign=center 
width=15FONT
   color=#ffnbsp;/FONT/TD

   /TR
;
}
echo /TBODY/TABLEbrbrbr;
  $next = $first_rec+50;
$prev_rec=$first_rec-50;
$this_rec = $next; //same record number as current, except 1-based
if ($this_rec  $num_recs)
   {
   echo div align=centerfont color=orange size=2stronga 
href='$PHP_SELF?first_rec=$next'
 Previuos /a/strong/font;
	}else{
   echo div align=center;

   }
echo font color=orange size=2strongnbsp; 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=2stronga href='$PHP_SELF?first_rec= 
$prev_rec' Next  /a;
	}



?

_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] problem with undefined variable

2003-06-04 Thread Griffiths, Daniel
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

Dan
-Original Message-
From: Ahmed Abdelaliem [mailto:[EMAIL PROTECTED]
Sent: 03 June 2003 16:21
To: [EMAIL PROTECTED]
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);
mysql_select_db(egycds);
$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 
$first_rec,
$max_rec);
while($record = mysql_fetch_array($test_tr))
{



echo 
TR onmouseover=\this.bgColor='00'\ 
onmouseout=\this.bgColor='475674'\ bgColor=#475674

TD width=75
DIV align=centerFONT
color=#ff;
echo stripslashes($record['date']) ;
echo /FONT/DIV/TD
TD width=90
DIV align=leftFONT color=white;
echo stripslashes($record['type']) ;
echo /FONT/DIV/TD
TDFONT 
color=#ffstrongnbsp;nbsp;A
href=\;
echo stripslashes($record['link']);
echo \ target=_new2;
echo stripslashes($record['name']);
echo /Anbsp;nbsp;/strong/FONT/TD

TD width=50
DIV align=leftFONT color=#ff;
echo stripslashes($record['cds']);
echo /FONT/DIV/TD TD width=80
DIV align=centerFONT color=#ff;
echo stripslashes($record['rate']);
echo /FONT/DIV/TD


TD width=70
DIV align=leftFONT color=#ffA
href=\;
echo 
stripslashes($record['downloaderlink']);
echo \;
echo stripslashes($record['downloader']);
echo /A/FONT/DIV/TD
TD align=middle vAlign=center 
width=15FONT
color=#ffnbsp;/FONT/TD

/TR
 ;
 }
 echo /TBODY/TABLEbrbrbr;
   $next = $first_rec+50;
$prev_rec=$first_rec-50;
$this_rec = $next; //same record number as current, except 1-based


if ($this_rec  $num_recs)
{
echo div align=centerfont color=orange size=2stronga 
href='$PHP_SELF?first_rec=$next'
 Previuos /a/strong/font;
}else{
echo div align=center;

}
echo font color=orange size=2strongnbsp; 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=2stronga href='$PHP_SELF?first_rec= 
$prev_rec' Next  /a;
}




?

_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] problem with undefined variable

2003-06-04 Thread Griffiths, Daniel
sorry, had written first_var instead of first_rec for some reason, should make more 
sense now!


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_rec as a 
global. Same thing for the PHP_SELF error.

So change this you need to get the value of $first_var like 
$first_rec=$_GET['first_rec'] 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

Dan

-Original Message-
From: Ahmed Abdelaliem [mailto:[EMAIL PROTECTED]
Sent: 03 June 2003 16:21
To: [EMAIL PROTECTED]
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);
mysql_select_db(egycds);
$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 
$first_rec,
$max_rec);
while($record = mysql_fetch_array($test_tr))
{



echo 
TR onmouseover=\this.bgColor='00'\ 
onmouseout=\this.bgColor='475674'\ bgColor=#475674

TD width=75
DIV align=centerFONT
color=#ff;
echo stripslashes($record['date']) ;
echo /FONT/DIV/TD
TD width=90
DIV align=leftFONT color=white;
echo stripslashes($record['type']) ;
echo /FONT/DIV/TD
TDFONT 
color=#ffstrongnbsp;nbsp;A
href=\;
echo stripslashes($record['link']);
echo \ target=_new2;
echo stripslashes($record['name']);
echo /Anbsp;nbsp;/strong/FONT/TD

TD width=50
DIV align=leftFONT color=#ff;
echo stripslashes($record['cds']);
echo /FONT/DIV/TD TD width=80
DIV align=centerFONT color=#ff;
echo stripslashes($record['rate']);
echo /FONT/DIV/TD


TD width=70
DIV align=leftFONT color=#ffA
href=\;
echo 
stripslashes($record['downloaderlink']);
echo \;
echo stripslashes($record['downloader']);
echo /A/FONT/DIV/TD
TD align=middle vAlign=center 
width=15FONT
color=#ffnbsp;/FONT/TD

/TR
 ;
 }
 echo /TBODY/TABLEbrbrbr;
   $next = $first_rec+50;
$prev_rec=$first_rec-50;
$this_rec = $next; //same record number as current, except 1-based


if ($this_rec  $num_recs)
{
echo div align=centerfont color=orange size=2stronga 
href='$PHP_SELF?first_rec=$next'
 Previuos /a/strong/font;
}else{
echo div align=center;

}
echo font color=orange size=2strongnbsp; 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=2stronga href='$PHP_SELF?first_rec= 
$prev_rec' Next  /a;
}




?

_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php