php script appends extra characters to query when deployed

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
irfanhab
Forum Newbie
Posts: 2
Joined: Sun Aug 06, 2006 10:27 pm

php script appends extra characters to query when deployed

Post by irfanhab »

Hi,

I have a php script that queries a database, When I deploy it locally in my server and I query with the following query:

Select * from patents where casename like '%microsoft%';

It works fine.

However when I deploy it to a remote hosted site, and I run the same query, It doesnt work, because it passes the following query:

Select * from patents where casename like \'%microsoft%\';

How do I remove those slasshes?? I even tried trimming the slashes in the string passed to the mysql server but it wont work.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

how is this string being created? (the code.)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

And what does

Code: Select all

$params = array('magic_quotes_gpc','magic_quotes_runtime','magic_quotes_sybase');
foreach($params as $p) {
	echo $p, ': ', ini_get($p) ? 'on':'off', "<br />\n";
}
print?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Sounds like you have addslashes() being applied somewhere.
irfanhab
Forum Newbie
Posts: 2
Joined: Sun Aug 06, 2006 10:27 pm

Post by irfanhab »

Everah wrote:Sounds like you have addslashes() being applied somewhere.
This is the Code where the error is occuring:

$query = $_POST["query"];
$query=trim($query,'\\');
print $query;

The query is passed to the script via a html form.

@voika

It displays this:
magic_quotes_gpc: on
magic_quotes_runtime: off
magic_quotes_sybase: off
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

magic_quotes_gpc: on
Take a look at http://de2.php.net/manual/en/ref.info.p ... quotes-gpc and http://de2.php.net/stripslashes
Can you change settings in the php.ini? Imho magic_quotes_gpc is one of the more #$*?!(censored) features of php.
Post Reply