$_GET & $HTTP_GET_VARS return different results

This is a discussion on $_GET & $HTTP_GET_VARS return different results within the PHP Language forums, part of the PHP Programming Forums category; Hi, Hoping someone can help, I have a sql query which is passed to the script via the url, this ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-03-2005
Chris Cox
 
Posts: n/a
Default $_GET & $HTTP_GET_VARS return different results

Hi,

Hoping someone can help, I have a sql query which is passed to the
script via the url, this is like:-

&stmt=select%20*%20from%20table%20where%20(%20stat us!='Closed'%20.....

If I look at $_GET['stmt'], this gives:-
select * from tickets where ( status=''Closed'' ......
If I look at $HTTP_GET_VARS['stmt'], this gives:-
select * from tickets where ( status=\'Closed\' ......

To get the query back again I run through stripslashes(), however
obviously this will have no affect with the $_GET['stmt'] variable.

So to my question, why am I getting differing results I believed that
the two variables were always the same, why is the ' not being escaped
with a \???

I am running php 5.0.3 on apache

Would appreciate some enlightenment, as I am beginning to pull my hair
out. I only have this problem with sqlite queries, mySQL queries are
escaped correctly in $_GET['stmt'].

Thanks in advance

Chris
Reply With Quote
  #2 (permalink)  
Old 03-03-2005
Alvaro G. Vicario
 
Posts: n/a
Default Re: $_GET & $HTTP_GET_VARS return different results

*** Chris Cox escribió/wrote (Thu, 03 Mar 2005 01:02:30 +0000):
> I have a sql query which is passed to the
> script via the url, this is like:-
>
> &stmt=select%20*%20from%20table%20where%20(%20stat us!='Closed'%20.....


So that the user can manually rewrite the URL to
"&stmt=DELETE%20FROM%0table"?


> If I look at $_GET['stmt'], this gives:-
> select * from tickets where ( status=''Closed'' ......
> If I look at $HTTP_GET_VARS['stmt'], this gives:-
> select * from tickets where ( status=\'Closed\' ......


Check this page: http://www.php.net/magic_quotes

If you cannot disable magic quotes for the whole server try to either
disable it for your script or detect it and unescape if necessary. Magic
quotes are evil.

Also, backup your database often, it'll get hacked pretty soon if you don't
change your design :)


--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:40 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0