0

In the PHP, in the value of $sql, why did we need the \ symbol (twice)?

//do the SQL
$sql = "UPDATE `starwars`.`Films` SET `Title` = 'Star Wars (aka \"A New Hope\")' WHERE `films`.`Episode` = 4";
$dosql = mysqli_query($connection, $sql);
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • 1
    `"UPDATE starwars.Films SET Title = 'Star Wars (aka "` this is a complete string otherwise. So it's little surprise to me you have to escape them or you'll get a syntax error. Like unexpected T_STRING from the PHP compiler deal `aka "` this ends the string because it matches the first quote. Without escaping – ArtisticPhoenix Jun 16 '22 at 20:13
  • Ps. I never got that one before that's how I know it so well.... lol. Happens all the time without a good IDE> – ArtisticPhoenix Jun 16 '22 at 20:16

0 Answers0