$PHP_SELF; hmmmmm

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

$PHP_SELF; hmmmmm

Post by toms100 »

im trying to do this

Code: Select all

<?php



$db = mysql_connect("localhost", "root");

mysql_select_db("mydb",$db);

$result = mysql_query("SELECT * FROM employees",$db);

if ($myrow = mysql_fetch_array($result)) &#123;

  do &#123;

    printf("<a href="%s?id=%s">%s %s</a><br>\n", $PHP_SELF, $myrow&#1111;"id"], $myrow&#1111;"first"], $myrow&#1111;"last"]);

  &#125; while ($myrow = mysql_fetch_array($result));

&#125; else &#123;

  echo "Sorry, no records were found!";	

&#125;

?>
i have windows xp pro, installed php using the installer program on php.net, installed mysql using an installer program on its site.
but when i try to do echo $PHP_SELF; i get this error:
Notice: Undefined variable: PHP_SELF in E:\Tom\php work\index.php on line 17
can anyone help me here?
Thanks

Tom
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

You can do one of two thigns here:
  • - Update your php.ini file to have register_globals = true or...
    - Change $PHP_SELF to $_SERVER['PHP_SELF']
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

thanks for your very helpful reply
i changed to $_SERVER['PHP_SELF'] and its working fine

many thanks

Tom:)
Post Reply