954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Search for string

Hi

I have a php code with a string that I'm trying to find in an MySql database.
But...I'm getting empty result set.

The database has a varchar column named news_url with this in it "/is/frettir/titill".

What I'm trying to do is search for this row with that string in the db.

I have a string variable in php

$curl = "/is/frettir/titill";

and this query:

SELECT * FROM news WHERE news_url LIKE '$curl'
(SELECT * FROM news WHERE news_url LIKE '/is/frettir/titill/')


I'm trying to find exactly that string. Not something like "/is/frettir/titill/morestuff" or "/is/frettir/" so what am I doing wrong? :/

Zedith
Newbie Poster
6 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 
$query = "SELECT * FROM news WHERE news_url = '$curl'";
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 
$query = "SELECT * FROM news WHERE news_url = '$curl'";

thanks pritaeas but I already tried that...still just get empty record set..

Zedith
Newbie Poster
6 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

Perhaps it is something else. Did you try in a database tool, or phpMyAdmin ?

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Yea tried that in phpmyadmin too with same results :/ kinda strange...
Might be something with the forward slashes. Will try to make another record without one just to test it.

Zedith
Newbie Poster
6 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

hum I'm onto something here.. when I added a record with the text "testtest" (no forward slashes) and I got results.
So I am assuming it has something to do with formatting the search then.

Zedith
Newbie Poster
6 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

I have no problems selecting this. Perhaps you have an older mysql version ? I've seen many forum posts with similar issues.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: