Author Topic: MYSQL WTF  (Read 2598 times)

Canuck

  • Eh?!!
  • Founders
  • Posts: 792
  • Karma: +51/-3
  • Andy Moog Fan
    • My Website
MYSQL WTF
« 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?

micah

  • A real person, on the Internet.
  • Ass Wipe
  • Posts: 6915
  • Karma: +58/-55
  • Truth cannot contradict truth.
    • micahj.com
Re: MYSQL WTF
« Reply #1 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 :-)
« Last Edit: February 19, 2007, 08:52:01 PM by micah »
"I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.  I use it to look at pictures of cats and get in arguments with strangers."

Canuck

  • Eh?!!
  • Founders
  • Posts: 792
  • Karma: +51/-3
  • Andy Moog Fan
    • My Website
Re: MYSQL WTF
« Reply #2 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!

Canuck

  • Eh?!!
  • Founders
  • Posts: 792
  • Karma: +51/-3
  • Andy Moog Fan
    • My Website
Re: MYSQL WTF
« Reply #3 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!

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: MYSQL WTF
« Reply #4 on: February 20, 2007, 11:10:51 AM »
Damn... too slow.  Sorry.

Canuck

  • Eh?!!
  • Founders
  • Posts: 792
  • Karma: +51/-3
  • Andy Moog Fan
    • My Website
Re: MYSQL WTF
« Reply #5 on: February 20, 2007, 06:11:43 PM »
>>Damn... too slow.  Sorry.

Haha, dont worry about :P

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: MYSQL WTF
« Reply #6 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