0

Using PhpStorm 2017.1.4

I have a MySQL query string in PHP:

<php

    $MySQL_Query_String = "SELECT * 
    FROM  `VISITOR` 
    WHERE  `ID` =3

    -- eventually add the date order here as well
    ORDER BY `VISITOR`.`INACTIVE` ASC, `VISITOR`.`NAME` ASC";

?>

I left a comment to remind myself of something with the -- to ignore that comment.

When I run this code in the browser - then this part is not being run by MySQL:

ORDER BY `VISITOR`.`INACTIVE` ASC, `VISITOR`.`NAME` ASC

When I debug - I see that the string is being concatenated and sent like this:

MySQL_Query_String = "SELECT * FROM  `VISITOR` WHERE  `ID` =3 -- eventually add the date order here as well ORDER BY `VISITOR`.`INACTIVE` ASC, `VISITOR`.`NAME` ASC";

The line return feeds are missing. The last line is now being ignored by MySQL.

The funny thing is - I have this exact same code in another application - using the same version of PhpStorm - and it does NOT remove the line feeds like the one mentioned here.

As far as I can tell - and I have copied both back and forth from each application - there is no difference.

I lost a number of hours debugging this. I did not immediately see that the lines returns were being ignored.

Why is PhpStorm removing the line feeds here?

  • You're missing the `$` before the variable name. How is that working? – Barmar May 31 '17 at 23:19
  • PhpStorm does not remove anything ... but your FTP server may adjust line ending symbols if misconfigured etc. I do see such behaviour one hosting even if I use FileZilla to upload/download. Please check what line endings do you have in this file right now. I say -- use Unix style (`\n`) if possible -- from my observations Mac/Windows line endings is when it gets broken. – LazyOne May 31 '17 at 23:19
  • There's a menu at the bottom right that controls the line break sequence. See if you have the same selection in both files. – Barmar May 31 '17 at 23:21
  • Out of curiousity, why not comment `/* like this */` so that your comments aren't dependent on line breaks? – Chris Forrence May 31 '17 at 23:23
  • Edited type-o thanks –  May 31 '17 at 23:42
  • Agree - /* comment */ Is probably better - lesson learned thanks –  May 31 '17 at 23:43
  • Menu at bottom right? U mean of PHPStorm editor? –  May 31 '17 at 23:44

0 Answers0