Page 1 of 1

[SOLVED] Problems sending variable trough URL

Posted: Mon Nov 17, 2003 8:13 pm
by Alfern
This is not the problem with register globals in the newer versions of PHP.

The server I use is running PHP 4.1.2, and register globals is on.

My problem is as follows:

When I send a variable in my URL like this: ....server/test.php?variable=test

and on the test.php page I have

<?
echo ("$variable");
?>

It returns nothing.

I have also tried $variable=$_GET['variable']; and
@extract($_GET);

but nothing seems to help.

Setting $variable=("test"); in test.php gives me the desired result though.

Any suggestions?

Posted: Mon Nov 17, 2003 8:34 pm
by Paddy
Looks fine to me. Could you use a different word besides variable? It could be a reserved word in HTML. I hate it when that happens...

Posted: Mon Nov 17, 2003 8:34 pm
by Weirdan
test.php:

Code: Select all

<?php
     ini_set("display_errors","1");
     ini_set("error_reporting","2047");
     echo "<pre>echo works if you see this message\n";
     echo "What we've got:\nREQUEST:";var_dump($_REQUEST);
     echo "\nPOST:";var_dump($_POST);
     echo "\nGET:";var_dump($_GET);
     echo ($variable);
?>

Posted: Mon Nov 17, 2003 9:06 pm
by Alfern
Paddy: the variable $variable was only an example !

Results from running test.php

echo works if you see this message
What we've got:
REQUEST:array(0) {
}

POST:array(0) {
}

GET:array(0) {
}

This was with test.php?test=1&test2=testing123

Posted: Mon Nov 17, 2003 9:08 pm
by Alfern
test.php?variable=test gave the same result.


Seems like there is an error with my service provider's php configuration.

You can test the page at http://www.alfern.com/capo2/info.php?variable=test . I also added phpinfo();

Posted: Tue Nov 18, 2003 3:48 am
by twigletmac
Have you spoken to your host about this? Maybe it's a problem with their Apache configuration? Can you post variables from a form?

Mac

Posted: Tue Nov 18, 2003 3:55 am
by JayBird
i think it is definately a problem with apache.

if you go to the phpinfo() page and scroll down to Apache Environment and look at QUERY_STRING (3rd from bottom), you'll see it is empty!

As twigletmac said, contact your host.

Mark

Posted: Tue Nov 18, 2003 4:47 am
by Alfern
Done that! Waiting for a reply from them. Posting with headers works fine.

Posted: Tue Nov 18, 2003 6:18 am
by Weirdan
Look at this:

Code: Select all

weirdan@office:~$ telnet www.alfern.com 80
Trying 204.251.10.212...
Connected to www.alfern.com.
Escape character is '^]'.
GET http://www.alfern.com/capo2/info.php?variable=test HTTP/1.1
Host: www.alfern.com

HTTP/1.1 200 OK
Date: Tue, 18 Nov 2003 12:16:21 GMT
Server: tigershark/3.0.111 (dn2.directnic.com)
Content-Type: text/html
Content-Length: 345

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
        <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <TITLE>alfern.com</TITLE>
</HEAD>
<FRAMESET rows="100%,*" border=0 frameborder=0 framespacing=0>
        <FRAME name=top src="http://home.no.net/alfern2/capo2/info.php" noresize>
</FRAMESET>
</HTML>
Connection closed by foreign host.
They use some sort of redirecter which is rewriting the request and do not include query string in it.

[edit]
Try this: http://home.no.net/alfern2/capo2/info.php?variable=test.
[/edit]

Posted: Tue Nov 18, 2003 10:37 am
by Alfern
Ok, now I know what is wrong :=)