954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

URL with query is not working...

<?php
if ($id == 1 && $lang == 1)
{
    echo "hello";
}
?>


hey guys i am working for my final year project. i have a problem. when i tried to run this url on my pc http://localhost/filename?id=1〈=1

it wouldn't work....

but when i tried this on my hosting, it will print out the word "hello".


my hosting is running php4....

and my pc is running php5...

does version matter?

Lomas
Newbie Poster
5 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

It has to do with the magic variables setting. Try using $_REQUEST['id'] and $_REQUEST['lang'] instead.

azimuth0
Light Poster
36 posts since May 2006
Reputation Points: 11
Solved Threads: 5
 
It has to do with the magic variables setting. Try using $_REQUEST['id'] and $_REQUEST['lang'] instead.

Thank you for replying.... really appreciate it...

i tried....

<?php
if ($_REQUEST['$id==1'] && $_REQUEST['$lang==1'])
{
    echo "hello";
}
?>


but its still not working...

how do i turn on the magic variables settings?

Lomas
Newbie Poster
5 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

no,no...

<ul><li><?php</li>
<li>if ($_REQUEST['id'] == 1 && $_REQUEST['lang'] == 1)</li>
<li>{</li>
<li>    echo "hello";</li>
<li>}</li>
<li>?></li>
</ul>
azimuth0
Light Poster
36 posts since May 2006
Reputation Points: 11
Solved Threads: 5
 

azimuth0... :)

Thank you very much..... its working now...

i just found out if u turn on the "register global" setting for php5 ... the old codes will work as well....

again.... thanks.... really appreciate your help...

Lomas
Newbie Poster
5 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 
<?php

if ($_GET['id'] == 1 && $_GET['lang'] == 1)
{
    echo "hello";
}
?>


- Mitko Kostov

MitkOK
Junior Poster
142 posts since Jul 2007
Reputation Points: 59
Solved Threads: 12
 

azimuth0... :)

Thank you very much..... its working now...

i just found out if u turn on the "register global" setting for php5 ... the old codes will work as well....

again.... thanks.... really appreciate your help...

It's better if you leave it off . Imagine how easy is for someone to hack your code .This is the reason why the developers set the register_globals off by default from php 4.2 . Instead u can use the EGPCS values ( Enviroment , Get , Post , Cookies , Server ) it's much safer

Eko
Junior Poster in Training
60 posts since Nov 2006
Reputation Points: 12
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You