Resolved: I have two queries one works one doesn’t using php and mysql?

In this post, we will see how to resolve I have two queries one works one doesn’t using php and mysql?

Question:

I am creating a movie database and I have a query that finds movies by their ID and it is working.
I then tried to make a query that would search for movies by title. So if I entered say “Alien” it would return any movies I own with the word “Alien in title. No matter what I have tried I get nothing returned and no errors.
Any points in the right direction is appreciated
I also tried a function to see if title is being passed by $_POST and it shows it is.

Best Answer:

Passing a value such as 'Alien' to the LIKE operator does not do what you expect.
This predicate…
… Actually behaves similarly as:
If you want to seach for titles that contain a given string, you need to use '%', the wildcard character :
You can either concatenate the percent sign in your code then inject it in the query, or pass the original value to the query and add the wildcard in SQL:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com