Sorry about the funny way of wording the title.
Also sorry if this is more of an sql question.
I'm using mysql by the way.
I've got a db column with values that have question marks in the strings stored in rows.
I want to use a $_GET to retrieve the values from a url and use the value to get the rows from the table in the db.
The only problem is with those question marks.
DIC.net doesn't have question marks in the string of their topics.
It still uses a url for the topic name even though question marks are in the topic titles.
How's it done?
I'm guessing some sort of wild card thing, or regex.
Another possibility is storing the name as a string in the db in a separate column from the actual title.
For instance the string that belongs to this topic would be in one column as:
Value in db has question mark. What about it in the query string?
Then in another column as:
value-in-db-has-question-mark-what-about-it-in-the-query-string
without punctuation.
but that would be some heavy duty duplication.
Just trying to get some feedback before I go through with creating the php code to do all this.
Not sure yet what mechanism I'm gonna use yet to solve this problem.
5 Replies - 505 Views - Last Post: 12 February 2012 - 09:45 PM
#1
Value in db has question mark. What about it in the query string?
Posted 12 February 2012 - 05:38 PM
Replies To: Value in db has question mark. What about it in the query string?
#2
Re: Value in db has question mark. What about it in the query string?
Posted 12 February 2012 - 05:58 PM
From the sounds of it is you've got a encoding problem. You can either remove the non alphanumeric characters or encode your query string when fetching it from the database. By query string I mean this
value-in-db-has-question-mark-what-about-it-in-the-query-string
#3
Re: Value in db has question mark. What about it in the query string?
Posted 12 February 2012 - 06:25 PM
If encoded how does that resolve the question mark that's already in the title that's stored?
Are question marks ignored in strings that are selected from a column in mysql?
I see there is a number in front of the topic title in the url of dreamincode.
Would that be an id that possibly is used to retrieve the actual topic, and the name of the topic is just a useful label up in the address bar.
Are question marks ignored in strings that are selected from a column in mysql?
I see there is a number in front of the topic title in the url of dreamincode.
Would that be an id that possibly is used to retrieve the actual topic, and the name of the topic is just a useful label up in the address bar.
This post has been edited by hiddenghost: 12 February 2012 - 06:26 PM
#4
Re: Value in db has question mark. What about it in the query string?
Posted 12 February 2012 - 07:15 PM
If you use prepared statements you won't have a problem with question marks, single/double quotes, or any other character in a data field.
#5
Re: Value in db has question mark. What about it in the query string?
Posted 12 February 2012 - 08:51 PM
CTphpnwb, on 12 February 2012 - 08:15 PM, said:
If you use prepared statements you won't have a problem with question marks, single/double quotes, or any other character in a data field.
Ok. How does that make it so the got $_GET value can be used to select a value from a db field with a question mark?
Being that the ? is not in the $_GET value.
#6
Re: Value in db has question mark. What about it in the query string?
Posted 12 February 2012 - 09:45 PM
Are you saying the URL looks like this?
If so, this code
produces:
testing?123
http://localhost/hiddenghost.php?example=testing%3F123
If so, this code
<?php
if(isset($_GET['example'])) {
echo $_GET['example'];
}
produces:
testing?123
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|