Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEWBIE Question on Literals

Status
Not open for further replies.

taqi

Programmer
Feb 10, 2003
4
GB
Hi
I have a COLUMN in a databse which stores a URL. I need to add new URLs WHERE there is no copy in the table.

The Problem is the WHERE clause when it comes to a string which has a '?' mark. I am using PHP to pass the stuff to the MySQL database. How can I pass a '?' (question mark) to the MySQL. I have tried all the following:

Putting it in quotes i.e. WHERE field='abd'?''
Putting it in double quotes i.e. WHERE field='abd"?"'
Using addslashes() or adding one manually i.e. WHERE field='abd/?'
Or even stciking into a vairable and trying to pass the variable.


None of the above work. I would REALLY appreciate any help.

Thanks

Taqi
 
I think the correct syntax is

'\?'

or if you need to include it in a where statement

where field=' \'?\'
Give me soem more detailed info on what you are trying to do, anyway use backslash and not forward slash.

I hope this helps


Bye

Qatqat
 
Hi

Thanks, just tried it, it does not work.

I have a field which has urls (URL) in a table (tbWebs) eg:
"
I want to be able to do a search whether such a URL exists by doing the following

SELECT * FROM tbWebs WHERE URL='
I tried your suggestion
SELECT * FROM tbWebs WHERE URL='and the following:
SELECT * FROM tbWebs WHERE URL='SELECT * FROM tbWebs WHERE URL='SELECT * FROM tbWebs WHERE URL='SELECT * FROM tbWebs WHERE URL='
MySQL is not taking the "?" literally. I just don't know how to ecape the character.
 
Hi sleipnir214

Isn't that what I posted before?

Bye

Qatqat
 
Thank you for you answers but, I am afraid the single escape does not work either i.e.

SELECT * FROM tbWebs WHERE URL='
I am using PHP to connect through to MySQL database and have come with a workable solution using the urlencode and urdecode functions. I am storing the URLs after urlencoding them, it gets rid all these troublesome characters with minimal programming.

Though I would be interested to know what MySQL version you are using which works with the escape for a '?'.
 
Hi

No I am not running into problems with PHP, I am echoing $sql and making sure that the query string is exactly as it should be. I have read in my pursuits on the internet that the problem may lie in the version of the MySQL, the MySQL documentation talks about Meta Characters but does not mention the '?' which is used as some sort of variable in MySQL, well so I think.

Anyways I have even double checked with the echoed string being put straight into the MySQL command line, so to speak. As soon as it hits the '?' it asks for its value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top