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? :/

$query = "SELECT * FROM news WHERE news_url = '$curl'";
$query = "SELECT * FROM news WHERE news_url = '$curl'";

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

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

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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.