Q&A, advice, reviews, and news about the computers, phones, TVs, stereos, and pretty much anything else that can't be easily whittled out of a stick or chipped out of stone.
-
asp55
- Redshirt
- Posts: 219
- Joined: Sat Mar 01, 2003 11:07 pm
- Real Name: Andrew S. Parnell
- Gender: Male
- Location: Portland, OR
-
Contact:
Post
by asp55 » Thu Jul 31, 2003 9:41 am
So I'm putting together a dynamic mysql database manager, and for some reason I'm coming across this little problem for editing or deleting (or simply selecting) an entry with an apostrophe in it.
By simply not specifying the section with the apostrophe everything works, but being that I am attempting to make this dynamic, that obviously isn't really an option in the long run.
Doesn't work
Code: Select all
DELETE FROM `forum` WHERE `id_datetime` = '20030731050650' AND `forums_main` = '1' AND `subject` = 'test' AND `body` = 'I\'m testing' AND `user_id` = '1' AND `thread_id` = '20030623214620'
works
Code: Select all
DELETE FROM `forum` WHERE `id_datetime` = '20030731050650' AND `forums_main` = '1' AND `subject` = 'test' AND `user_id` = '1' AND `thread_id` = '20030623214620'
Anyone have any idea's as to how to break it's will and make it work?
-
Martin Blank
- Knower of Things

- Posts: 12709
- Joined: Fri Feb 07, 2003 4:11 am
- Real Name: Jarrod Frates
- Gender: Male
- Location: Dallas, TX
-
Contact:
Post
by Martin Blank » Thu Jul 31, 2003 2:13 pm
Are you getting back a particular error if you run this in MySQL?
If I show up at your door, chances are you did something to bring me there.
-
asp55
- Redshirt
- Posts: 219
- Joined: Sat Mar 01, 2003 11:07 pm
- Real Name: Andrew S. Parnell
- Gender: Male
- Location: Portland, OR
-
Contact:
Post
by asp55 » Thu Jul 31, 2003 8:50 pm
Nope, that's what's baffling me about it. The query goes off without a hitch, but doesn't bring up anything. It?s weirding me out.
I once had a signature.
-
Martin Blank
- Knower of Things

- Posts: 12709
- Joined: Fri Feb 07, 2003 4:11 am
- Real Name: Jarrod Frates
- Gender: Male
- Location: Dallas, TX
-
Contact:
Post
by Martin Blank » Thu Jul 31, 2003 10:11 pm
You should get back a number of rows affected. Is it coming back "0 rows" or "1 row" or what?
If I show up at your door, chances are you did something to bring me there.
-
asp55
- Redshirt
- Posts: 219
- Joined: Sat Mar 01, 2003 11:07 pm
- Real Name: Andrew S. Parnell
- Gender: Male
- Location: Portland, OR
-
Contact:
Post
by asp55 » Thu Jul 31, 2003 11:34 pm
it was 0 rows
(note: this is a database manager I was working on building in php)
set it so that it just does a query for the primary key, and now it works...though I'm still a little confused why the original query wasn't effecing the row. It's weird.
I once had a signature.
-
Martin Blank
- Knower of Things

- Posts: 12709
- Joined: Fri Feb 07, 2003 4:11 am
- Real Name: Jarrod Frates
- Gender: Male
- Location: Dallas, TX
-
Contact:
Post
by Martin Blank » Fri Aug 01, 2003 3:55 am
If you're passing the code in PHP, it may be auto-escaping the \ and the ' for you, meaning the database is getting this for a query:
Code: Select all
DELETE FROM `forum` WHERE `id_datetime` = '20030731050650' AND `forums_main` = '1' AND `subject` = 'test' AND `body` = 'I\\\'m testing' AND `user_id` = '1' AND `thread_id` = '20030623214620'
Since you don't have an entry like that, it returns 0 rows.
Unless, of course, you've run that query directly in MySQL, in which case I'm off-base.
If I show up at your door, chances are you did something to bring me there.
-
Mandor
- Redshirt
- Posts: 2261
- Joined: Thu Apr 10, 2003 8:01 am
Post
by Mandor » Fri Aug 01, 2003 7:13 am
There is absolutly no reason PHP would auto escape the "\". Still if you are using PHP, you can probably make a test based on stripslashes(), but still I don't think it matters really.
Try by replacing the single quotes by double quotes, just to see if the problem comes from the escape of your single quote in the "I'm testing".
Who is online
Users browsing this forum: No registered users and 1 guest