1

I write this query in PHP.

Example

$name='MIKE & JOHN';
$query = "DELETE * FROM `user` WHERE `name` = '$name'";

When it actually executes it shows like below...

echo"$query";

Output:-

DELETE * FROM `user` WHERE `name`= 'MIKE';

As the output shows after MIKE, they ignored the whole sentence. Now how to solve this problem?

Pls, help guys thanks in advance.

Smart Tech100
  • 33
  • 1
  • 4
  • 2
    Yet another problem you wouldn't have with [parameterized queries](https://stackoverflow.com/questions/4712037/what-is-parameterized-query) so now's probably the right moment to learn about them and consequently start using them everywhere. As a bonus, you won't have any problems with sql injection anymore. – fvu Oct 28 '17 at 11:52
  • 1
    `DELETE *` is a nonsensical construction – Strawberry Oct 28 '17 at 11:55
  • I would recomend to look up the [pdo](http://php.net/manual/en/intro.pdo.php) – Gordon Freeman Oct 28 '17 at 11:58

1 Answers1

0

I try it and this ok DELETE * FROM `user` WHERE `name` = 'MIKE & JOHN'[Finished in 0.2s] if you trying send $name result via http GET link check it var_dump($_GET), http split it.

CrazyBite
  • 1
  • 1