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
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Fri Jan 28, 2005 8:14 am
Hi,
I'm trying to record a data element into a MySQL database which includes forward slashes ('/').
Am I correct in that MySQL doesn't like / characters in text fields, and so you have to use stripslashes(), or is there some other way?
Many thanks
Mark
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 28, 2005 8:16 am
forward slashes don't matter... it's quotes which are duplicates of the ones used to create the mysql string that are the problem.
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Fri Jan 28, 2005 8:23 am
I get an error for the following query :-
SELECT PageID FROM 4e58fbc769d276713def15dbd0065de6 WHERE PageURL='
http://uk.yahoo.com/ '
???
Many thanks
Mark
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 28, 2005 8:30 am
what does the error say?
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Fri Jan 28, 2005 8:31 am
Code: Select all
Error: Could not perform MySQL query - You have an error in your SQL syntax near '4e58fbc769d276713def15dbd0065de6 WHERE PageURL='http://uk.yahoo.com/'' at line 1
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 28, 2005 8:32 am
that has to do with your table name... place it in backticks: `
note ` is not '
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Fri Jan 28, 2005 8:35 am
weird - why is that?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 28, 2005 8:36 am
it's not recognized natively as a table's name.... or rather a reference to data for MySQL
Joe
Forum Regular
Posts: 939 Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow
Post
by Joe » Sat Jan 29, 2005 2:32 pm
You may be able to use entities. Give it a try!
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sat Jan 29, 2005 2:45 pm
SELECT PageID FROM 4e58fbc769d276713def15dbd0065de6
woooow, in that case i would choose a different table name.
as already mentionned, escaping with backtick the name will do too.