Re: PHP and MySQL form problem - Undifined variables
| From: | Kris Newton | Date: | Fri, 25 Oct 2002 21:06:36 +0000 |
| Subject: | Re: PHP and MySQL form problem - Undifined variables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22710@lists.php.net to get a copy of this message | ||
Mario,
The one neat thing about PHP is when something goes wrong with the code, it
usually tells you where the error is happening and like a small reason why.
On line 11 of your code, you have:
$PHP_SELF,
this is the variable that needs to be defined as to what this string is
supposed to be.
PHP is trying to find out what the string $PHP_SELF is, so you going to
need to put something in your code to do this. Hope this helps some.
"Mario Montag" <mmontag@bellsouth.net> wrote in message
news:20021025170041.51178.qmail@pb1.pair.com...
> 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>
>
> //-------------- END OF CODE -----------------------------------
>
> 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
> mmontag@bellsouth.net
>
>
>
>
>
>