[SOLVED] Problems sending variable trough URL

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
Alfern
Forum Newbie
Posts: 5
Joined: Mon Nov 17, 2003 8:13 pm

[SOLVED] Problems sending variable trough URL

Post 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?
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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...
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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);
?>
Alfern
Forum Newbie
Posts: 5
Joined: Mon Nov 17, 2003 8:13 pm

Post 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
Alfern
Forum Newbie
Posts: 5
Joined: Mon Nov 17, 2003 8:13 pm

Post 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();
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
Alfern
Forum Newbie
Posts: 5
Joined: Mon Nov 17, 2003 8:13 pm

Post by Alfern »

Done that! Waiting for a reply from them. Posting with headers works fine.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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]
Alfern
Forum Newbie
Posts: 5
Joined: Mon Nov 17, 2003 8:13 pm

Post by Alfern »

Ok, now I know what is wrong :=)
Post Reply