5 Replies - 852 Views - Last Post: 12 February 2012 - 09:45 PM Rate Topic: -----

#1 hiddenghost  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Value in db has question mark. What about it in the query string?

Posted 12 February 2012 - 05:38 PM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: Value in db has question mark. What about it in the query string?

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 944
  • View blog
  • Posts: 2,353
  • Joined: 15-February 11

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

Was This Post Helpful? 0
  • +
  • -

#3 hiddenghost  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

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.

This post has been edited by hiddenghost: 12 February 2012 - 06:26 PM

Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2895
  • View blog
  • Posts: 10,027
  • Joined: 08-August 08

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.
Was This Post Helpful? 0
  • +
  • -

#5 hiddenghost  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Re: Value in db has question mark. What about it in the query string?

Posted 12 February 2012 - 08:51 PM

View PostCTphpnwb, 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.
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2895
  • View blog
  • Posts: 10,027
  • Joined: 08-August 08

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?
http://localhost/hiddenghost.php?example=testing%3F123

If so, this code
<?php
if(isset($_GET['example'])) {
echo $_GET['example'];
}

produces:
testing?123
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1