0

I have the code below to search for the text 'english' anywhere in the field language. I've tried formatting the code from SQL into a web PHP page but it doesn't display any information. When I run the sql version select language from media where language like '%english%' it works.

$result = mysql_query("SELECT `language` FROM `media` WHERE `language` LIKE \'%english%\'");

while ($row = mysql_fetch_array($result)) {
echo $row[''];
echo ' ' , $row['language'];
echo '<br />';
}

2 Answers 2

1

Don't escape the single quotes around your search term.

$result = mysql_query("SELECT `language` FROM `media` WHERE `language` LIKE '%english%'");
Sign up to request clarification or add additional context in comments.

1 Comment

I'm using phpmyadmin and it formatted the php code with the \. thanks its working now.
1

You don't need to escape the ''s. It should just work. So try this:

$result = mysql_query("SELECT `language` FROM `media` WHERE `language` LIKE '%english%'");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.