0

My code looks like this

 $eventname = "music festival 5";
 $stmt  = $pdo->prepare('SELECT * FROM events WHERE eventname=?');
 $stmt->execute([$eventname]);
 $row = $stmt->fetchAll();

The above gives no result. When I change the following line, it works:-

$stmt  = $pdo->prepare('SELECT * FROM events WHERE eventname="music festival 5"');

What could be the issue? Please suggest. Thank you.

burf
  • 153
  • 2
  • 8
  • @your_common_sense your suggestion does not answer my question... can you please reopen it? – burf Feb 17 '20 at 14:43
  • Why should it be reopened? Prove to us that the solution suggested is not the right one. – Dharman Feb 17 '20 at 15:19
  • @Dharman, I am struggling to solve the issue and if i would have been able to prove, i would well have been able to find the problem and maybe solve it. I am not saying it is wrong, I am saying it did not solve my particular issue... why do you take offense if you do? I followed the steps suggested by your_common_sense in that thread. 1, I am already using the PDO statements and 2, I did not find any spaces or any other characters... I suspect double quotes but without them the string would not match. – burf Feb 18 '20 at 13:22
  • The thing is you never updated your post with additional findings. To us the problem still looks like a whitespace problem. Unless you show us the output of `var_dump($eventname)` and describe what else you have done to debug this issue we have no reason to vote to reopen. It's only logical that you need to update the question with more details explaining why the solution proposed is not the solution for you. Don't just tell us you read it, tell us how you came to a conclusion that it is not the whitespace problem. – Dharman Feb 18 '20 at 13:26
  • Thanks anyway Dharman for your insistence... I found it! the problem was the extra set of double quotes. The argument being passed was `""music festival 5""` and not `"music festival 5"` – burf Feb 18 '20 at 13:50

0 Answers0