wierd variables

Started on the old forum in April 2012 · view the original in the archive · old links redirect here

13 replies · 619 views · started 14 years ago · 1 min read

3 participants
pmbguy Senior · 344 posts #1

ok, i'm trying to install a script i coded on hostgator... Script works great on other hosts, but for some reason on hostgator i find its not reading any $_GET's, so i'm like wtf, n then just by chance, i try $_REQUEST n it works, so I quickly run mreplace on script replacing all $_GET for $_REQUEST and upload script again...

It works perfectly mn I'm like yay!!! then turn my head back to screen only to see its not reading $_REQUEST now... so i check $_GET n it's reading, i'm thinking wtf as i mreplace script to revert to original $_GET, n upload... halfway through uploading it switches back n starts only reading variables via $_REQUEST again...

To cut a long boring repetetive story short, I been at this for hours back n forth ftp n re ftp, n chatting to online support, etc but they can't find problem in logs nor do they seem to understand what $_GET is, lol... So I decided to to try asking here, n the reason I posted in coding is cause I'm currently trying to figure out how to code a switch that will check n swap $_GET n $_REQUEST so the site works for longer than 30 seconds... But everything I try has failed... So far I'm back to:

if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } else { $action = $_GET['action']; }

but even this just throws blanks... WTF is going on?

pmbguy Senior · 344 posts #3

similar, but my problem is the server keeps swapping and one moment $_GET returns something, next moment $_REQUEST, almost as if when i change script between them it triggers the server to disable the one i change code to...

First time I put a script on hostgator, i think they ared crap... Script runs fine on every other server i used... Just hostgator got something funky going on... Cause it shouldn't be needing to be modified every 30 seconds if that makes sense...

something else Fellow · 2,296 posts #4

try putting this at top of script to see if it solves the GET problem:

if(isset($_GET)){foreach($_GET as $key=>$value){$_GET[$key]=mysql_escape_string($value);}} 

if it does you have same problem as me

something else Fellow · 2,296 posts #6

what if you upload 2 pages at same time: index_request.php index_get.php ? probably a stupid suggestion ^

try

 print_r($_GET);
arnage Lead · 811 posts #7

Hi bro, long time no see. 🙂

But why you canceling REQUEST? Its GET and POST (in that order). So or do like this:

$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';

Or:

if (isset($_POST['action']))
 {
 $action = $_POST['action'];
 }
 else
 {
 $action = $_GET['action'];
 }

In fact, this last one to be precise:

if (isset($_POST['action'])) 
 { 
 $action = $_POST['action']; 
 } 
 else 
 { 
if (isset($_GET['action'])) 
{
 $action = $_GET['action']; 
} else {
 $action = '';
}
 } 

This is why is ternary really good. 😉

$action = isset($_GET['action']) ? $_GET['action'] 
: (isset($_POST['action']) ? $_POST['action'] : '');

This is like $_REQUEST['action'], more or less.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
something else Fellow · 2,296 posts #8

Just out of interest what script editor are you using?

arnage Lead · 811 posts #9

Me? Just Notepad++ in Total Commander.

When i mentioning ternary, it relay can be interesting. Here was some grabber script, i can't remember in what topic but it name was xxx2. This is how i retrieved title for pages. 🙂

$title = empty($_GET['dir']) ? (empty($_GET['file'])
 
	? 'Home' : (empty($_GET['name'])
 
	? '' : (mb_strlen(base64_decode($_GET['name']), 'UTF-8') > 15
 
	? htmlentities(capsfirst(str_replace('_', ' ', mb_substr(base64_decode($_GET['name']), 0, 15, 'UTF-8').'...')), ENT_QUOTES, 'UTF-8')
 
	: htmlentities(capsfirst(str_replace('_', ' ', base64_decode($_GET['name']))), ENT_QUOTES, 'UTF-8'))))
 
	: htmlentities(capsfirst(str_replace(array('tags/', '/'), '', $_GET['dir'])), ENT_QUOTES, 'UTF-8');
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
something else Fellow · 2,296 posts #10

arnage wrote: Me? Just Notepad++ in Total Commander.

na was at pmbguy 🙂.... i normally use notepad++ but just realized i used dreamweaver for editing script that i have got problems with.... so i was thinking maybe a problem with "$" symbol and dreamweaver ..... (dreamweaver caused me a problem with a symbol before a few years ago but i cant remember what it was)

eg typing $_GET once works fine when you type it in manually but using replace all could be changing the character encoding on the "$" symbol therefor making the $_GET invalid

^ this is a guess and not a fact

arnage Lead · 811 posts #11

Ooops. 🙂

Well Notepad knows to change encoding also where are no utf8, so i set it to UTF8 without BOM and write comment on top of pages:

<?php
/* šđžćč */
// ...
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
pmbguy Senior · 344 posts #12

Ok, i'm using a PHP editor, n the code in srcipt is fine, if you look at YFCASA thats working fine, if it picks up if $_GET['action']=="mobile" n runs... it's gotr browser detect to divert between mobile n PC, now on hostgator $_GET['action'] returns blank, but $_REQUEST['action'] returns mobile or main or pc etc... if I change script using mreplace (this app works too, used it millions of times, in fact pretty much everything i put on coding-talk most likely been mreplaced a few times in coding), anyhow if I change my $_GET's to $_REQUESTS, then suddenly $_GET starts giving variables, n $_REQUEST stops returning variables... Like I did this back n forth all day yesterday for hours, n its like the serve keeps disabling whichever one i put in the code, thats the only way i can explain this... The script works 100% just not reading action= or loguser= or logpass or sid or anything, therefore the script returns else action or says invalid username, etc...

arnage Lead · 811 posts #13

But there is no point switching between $_REQUEST and $_GET, $_GET is in $_REQUEST, thats the problem. PHP: $_REQUEST - Manual

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
something else Fellow · 2,296 posts #14

pmbguy wrote: Ok, i'm using a PHP editor, n the code in srcipt is fine, if you look at YFCASA thats working fine, if it picks up if $_GET['action']=="mobile" n runs... it's gotr browser detect to divert between mobile n PC, now on hostgator $_GET['action'] returns blank, but $_REQUEST['action'] returns mobile or main or pc etc... if I change script using mreplace (this app works too, used it millions of times, in fact pretty much everything i put on coding-talk most likely been mreplaced a few times in coding), anyhow if I change my $_GET's to $_REQUESTS, then suddenly $_GET starts giving variables, n $_REQUEST stops returning variables... Like I did this back n forth all day yesterday for hours, n its like the serve keeps disabling whichever one i put in the code, thats the only way i can explain this... The script works 100% just not reading action= or loguser= or logpass or sid or anything, therefore the script returns else action or says invalid username, etc...

Try this..... if it works then its your php editor ..... if not then get your money back from hostgator

Attachments: test.zip

Sign in to reply.

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close