Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables doesn't works

Status
Not open for further replies.

egmweb

Programmer
Mar 19, 2004
147
EU
Hello all.

I'm making a website based on php/mysql and I have some functions which I include in index.php at begin of this file.

But I have a problem with the variables... when I send a variable through get method to the next .php page, it displaay the following errors:

Notice: Undefined variable: error in C:\Apache2\htdocs\pcplus\index.php on line 257

thanks you.
 
hi, No sorry, but i'm not understanding what've you said in this code....

I have a Index.php and it has html.

I have different static links in the category menu:

Tools > link: index.php?catid=2
Misc > link: index.php?catid=3 etc.... in the first index.php I have no form to send this variables... justo click on the link and I'm sending the variable through url.

But I think that the code is fine, because it was working good before.... Some guy edit the php.ini and the website doesn't works...

Thanks you
 
I forgot to tell you that The Version of PHP is 4.3.4
 
The values submitted in the URL have to be going somewhere. The most likely place is $_GET.

If you create a PHP script called show_get.php, which reads:

Code:
<?php
print '<html><body><pre>';
print_r ($_GET);
print '</pre></body></html>';
?>

And you point your browser to [ignore][/ignore], what is output to the browser?



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Sorry it took me so long to come back to the thread.
DrJ said:
...This actually is not a Warning, it is merely a notice...
My mistake, just a Notice.

but still Checking the setting for the directive i mentioned is not a bad idea. I agree with Sleipnir on checking what is actually contained in the $_GET superglobal.

Also, you asign $error the value of $_GET['error'] at the beggining of the script, but where do you use it.

I gonna take a stab in the dark here:
If you use it inside a function somewhere it has to be passed into the function for example if you do this:

Code:
$error=$_GET['error'];

And then have function that uses it like so:

function check_error(){
if($error=='somevalue'){
do something
}
}

This will generate a notice since [red]$error[/red] is not defined in the function's scope. You have to pass to the function or define it as a global variable.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I really wish there were an option to edit ones post any way, what i forgot to say is:

You told us you get this error:
egarcia said:
Notice: Undefined variable: error in C:\Apache2\htdocs\pcplus\index.php on line 257
Can you tell us what is in line 257 of your code.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top