Results 1 to 11 of 11
-
03-07-2004, 11:42 AM #1Junior Guru
- Join Date
- Aug 2003
- Location
- Walsall - UK
- Posts
- 177
PHP/mySQL slashing causing problems searching...
Hey guys...
I have entries in my mySQL database that are slashed, e.g: Nick\\'s Cars
But the problem is when I come to call it from the database without a slash like this: Nick\'s Cars
I addslashes before the query is carried out:
PHP Code:$company_name=addslashes($company_name);
$query="SELECT * FROM tod_company_information WHERE company_name='$company_name' ORDER BY $sort ASC";
$result=mysql_query($query);
Any ideas?
Thanks in advance
crE<<< Please see Forum Guidelines for signature setup. >>>
-
03-07-2004, 11:46 AM #2Junior Guru
- Join Date
- Aug 2003
- Location
- Walsall - UK
- Posts
- 177
Ok, I just realised it was backslashed anyway without me needing to addslashes... But it still didn't give me a result!
<<< Please see Forum Guidelines for signature setup. >>>
-
03-07-2004, 11:52 AM #3Web Hosting Master
- Join Date
- Jul 2002
- Location
- UK
- Posts
- 2,027
echo $query;
paste what it says.
try pasting the output and manually running it on the database and see what it says (may be an error)Gone.
-
03-07-2004, 12:14 PM #4Junior Guru
- Join Date
- Aug 2003
- Location
- Walsall - UK
- Posts
- 177
This is the query as it stands:
PHP Code:SELECT * FROM tod_company_information WHERE company_name="Nick\\\\'s Cars" ORDER BY company_name ASC
crE<<< Please see Forum Guidelines for signature setup. >>>
-
03-07-2004, 12:28 PM #5Web Hosting Master
- Join Date
- Jul 2002
- Location
- UK
- Posts
- 2,027
try making it so it's:
PHP Code:SELECT * FROM tod_company_information WHERE company_name='Nick\'s Cars' ORDER BY company_name ASC
Gone.
-
03-07-2004, 12:34 PM #6Junior Guru
- Join Date
- Aug 2003
- Location
- Walsall - UK
- Posts
- 177
I tried using double and single quotes - but neither work!
crE<<< Please see Forum Guidelines for signature setup. >>>
-
03-07-2004, 08:34 PM #7Disabled
- Join Date
- Mar 2004
- Posts
- 23
you need to escape the /'s...
-
03-07-2004, 08:38 PM #8Disabled
- Join Date
- Mar 2004
- Posts
- 23
there should be a function for this on the php website,
-
03-07-2004, 08:42 PM #9Disabled
- Join Date
- Mar 2004
- Posts
- 23
sorry for all the posts, had to post 5 posts before i could post a url to another site
http://us4.php.net/manual/en/function.addslashes.php
the above should be really helpful,
-
03-09-2004, 03:45 PM #10Junior Guru
- Join Date
- Aug 2003
- Location
- Walsall - UK
- Posts
- 177
I looked on the link and used this "urlencode" syntax.. it works good! Thanks acewebi!! You tha man
crE<<< Please see Forum Guidelines for signature setup. >>>
-
03-15-2004, 09:39 AM #11Web Hosting Master
- Join Date
- Feb 2004
- Posts
- 772
Hi,
Whenever you are using slash operator you have to make it execute in your script by escaping that operator. So use backslash before the slash operator to make it print.
Regards,
Bright