PHP Select Statement and Special Signs

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Bogdan Zagan
Forum Newbie
Posts: 7
Joined: Wed May 29, 2002 2:15 am
Location: Romania

PHP Select Statement and Special Signs

Post by Bogdan Zagan »

How can I make a select if the database field is something like 'AAA\BBB.CCC'
Bogdan Zagan
Forum Newbie
Posts: 7
Joined: Wed May 29, 2002 2:15 am
Location: Romania

Post by Bogdan Zagan »

I used the

Code: Select all

<?php echo $HTTP_GET_VARS&#1111;"textfield"]; ?>
to see what is actually passed into the SELECT statement.

When I enter in the text field the value
AAA\BBB.CCC
, the output is
AAA\\BBB.CCC
, so the PHP modifies my textfield entered value because of the containing \ sign.
Can I escape from this ?
Because in the database the field contains values like AAA\BBB.CCC, so I need to make a SELECT.
Bogdan Zagan
Forum Newbie
Posts: 7
Joined: Wed May 29, 2002 2:15 am
Location: Romania

Post by Bogdan Zagan »

The web server is Apache on Linux
The DataBase server is MsSql on Windows
The conection is made using FreeTds
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Try enclosing it in quotes.

But you should really avoid having any characters like that in a database field name or table name.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

try using

Code: Select all

stripslashes($HTTP_GET_VARS&#1111;"textfield"]);
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

so the PHP modifies my textfield entered value because of the containing \ sign
This is caused by having magic_quotes_gpc on in your php.ini file.
php.net wrote:Sets the magic_quotes state for GPC (Get/Post/Cookie) operations. When magic_quotes are on, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a backslash automatically.
Mac
Post Reply