-2

I have a problem calling the database in the URL with MYSQL, where I call the url post

/post/**how-to-noodle-with-egg**

why does the database call an error with a strip at the URL?

if me display in page use

$_GET['title'];

why only get "how"? why not get full url? so page post me not found data because only get "how" not full text with strip

My code :

$a = $_GET['title'];

"SELECT * FROM `post` WHERE title = '$a";

in my database title : how-to-noodle-with-egg ( use strip )

maybe someone here can help my problem

olibiaz
  • 2,551
  • 4
  • 29
  • 31
Aing Macan
  • 177
  • 11

1 Answers1

-1

Your SQL query is missing trailing ':

"SELECT * FROM post WHERE title = '$a";

Should be:

"SELECT * FROM post WHERE title = '$a'";

I'd also strongly suggest to properly escape $a to avoid SQL injections.

5lava
  • 1,168
  • 11
  • 12