EntropySink

Technical & Scientific => Software => Topic started by: Canuck on February 19, 2007, 08:07:29 PM

Title: MYSQL WTF
Post by: Canuck on February 19, 2007, 08:07:29 PM
I was updating my autograph site and came across something..

This is the second time this has happened, something works locally, and when I upload it, it doesnt work the same.

I have a query to grab stats for the player.

It should display it as follows:

http://ttm.kranjcevic.com/display_ttm_info.php?id=Hull+Brett

for players with an apostrophe in their last name, it wont display.

http://ttm.kranjcevic.com/display_ttm_info.php?id=O'Marra+Ryan



Using mysqladmin on the server, I put in the following query

SELECT f_name, l_name, sent, team, league, received, wait FROM ttm where f_name =
"Ryan" and l_name = "O'Marra" order by sent DESC

which works.

before I strip the slashes the text is O\'Mara, and if I strip the slahes and perform the SQL query, it doesnt work locally.

I dont know whats going on!

Suggestions?
Title: Re: MYSQL WTF
Post by: micah on February 19, 2007, 08:49:22 PM
my guess is it has to do the your PHP configuration on each server.
one probably has magic_quotes_gpc = ON and the other doesn't.

http://us3.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc

see also: http://us3.php.net/addslashes which also comments on the magic_quotes issue.

but who knows. I'm sure Ober will correct me if (read: when) i'm wrong :-)
Title: Re: MYSQL WTF
Post by: Canuck on February 19, 2007, 09:10:06 PM
I just ran the function get_magic_quotes_gpc(); and it is set to 1 on my local machine and 0 the server Im working on, so Im going to look into resolving the issue.

Thanks!
Title: Re: MYSQL WTF
Post by: Canuck on February 19, 2007, 10:02:18 PM
I changed my local settings to match those of the server, and got it to work.. I had to add slashes before I read from the DB, which I removed earlier in the program..

At least it works.. Thanks again micah!
Title: Re: MYSQL WTF
Post by: ober on February 20, 2007, 11:10:51 AM
Damn... too slow.  Sorry.
Title: Re: MYSQL WTF
Post by: Canuck on February 20, 2007, 06:11:43 PM
>>Damn... too slow.  Sorry.

Haha, dont worry about :P
Title: Re: MYSQL WTF
Post by: Perspective on March 09, 2007, 12:06:53 PM
For future refs, using double quote does not mean a string in SQL, the standard uses single quotes (which is the same char as your apostrophe). MySQL must allow both