As was already mentioned, $_SERVER['PHP_SELF'] is what you want.  But on a
side note you may consider changing the way you're checking for results in
that if() statment.  You will end up with another error if no records are
returned.  So instead you should check for the nubmer of records returned
with..

if (mysql_num_rows($result) > 0)
{
 //..
}

Just one of those little details you don't learn about until you're staring
down a cryptic error message.  :)

-Kevin

----- Original Message -----
From: "Mario Montag" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 25, 2002 10:48 AM
Subject: [PHP] Simple form problem -


> First time playing with PHP, Apache, and MySQL.  I have a simple form
error
> and I don't know how to solve it.  I was doing the Webmonkey PHP/MySQL
> tutorial and when I started using forms with $PHP_SELF I started getting
> errors with variables not defined.
>
> PHP 4.2.3
> MySQL 4.0 Windows 2000
> Apache 1.3.27 (Since I was not able to get 2.0 working on Windows 2K Pro)
>
> My code is:
>
> //----------  START OF CODE --------------
> <html><body><?php
>
> $db = mysql_connect("localhost", "root");
> mysql_select_db("mydb",$db);
> $result = mysql_query("SELECT * FROM employees",$db);
>
> if ($myrow = mysql_fetch_array($result)) {
>   do {
>     printf("
>  <a href=\"%s?id=%s\">%s %s</a><br>\n",
>  $PHP_SELF,
>  $myrow["id"],
>  $myrow["first"],
>  $myrow["last"]
>     );
>   } while ($myrow = mysql_fetch_array($result));
> }
>
> else {
>   echo "Sorry, no records were found!";
> }
>
> ?>
> </body></html>
>
> //-------------------------------------------------
>
> My ERROR is:
>
> Notice: Undefined variable: PHP_SELF in C:\Program Files\Apache
> Group\Apache\htdocs\mysql2.php on line 11
> Bob Smith
>
> Notice: Undefined variable: PHP_SELF in C:\Program Files\Apache
> Group\Apache\htdocs\mysql2.php on line 11
> John Roberts
>
> Notice: Undefined variable: PHP_SELF in C:\Program Files\Apache
> Group\Apache\htdocs\mysql2.php on line 11
> Brad Johnson
>
> Notice: Undefined variable: PHP_SELF in C:\Program Files\Apache
> Group\Apache\htdocs\mysql2.php on line 11
> Mar f
>
> ---------------  END OF ERROR  ----------------------------
>
> I am able to connect to the MySQL DB and retrieve info, but I don't get
the
> error.  I changed the REGISTER_GLOBALS of the php.ini file to ON and I
still
> get the variables error.  I also added $_POST  as stated in another form
> issue but it did not resolve my problem.  It must be simple but I don't
know
> enough to identify the issue.
>
> Thanks for any help or input.
>
> Mario
> [EMAIL PROTECTED]
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



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

Reply via email to