title: SQL command split into multiple php lines
body: <p>I have to split up this SQL command and now I have a problem with the gazillion number of quotation marks. Can someone please help?? (I'm trying to dynamically assign a filename to the OUTFILE which must include a current timestamp as part of the filename). Thanks.</p>
  
  <pre><code>&lt;?php 
  
    $sql_query = "SELECT @myCommand := concat("'SELECT UNIX_TIMESTAMP( TIMESTAMP( CURDATE( ) , HalfHourTime ) ), 0, 0, 0, 0 '";
    $sql_query =$sql_query . into OUTFILE 'C:/wamp/www/myApp/services/csv/filename-", 'DATE_FORMAT(now(),"%Y%m%d-%H%i%s")', '.csv' "' ';
    $sql_query =$sql_query . FIELDS TERMINATED BY ','  ';
    $sql_query =$sql_query . LINES TERMINATED BY '\n'';
    $sql_query =$sql_query .FROM timeintervals_halfhours';
    $sql_query =$sql_query . ');";
    $sql_query =$sql_query . "PREPARE stmt FROM @myCommand; ";
    $sql_query =$sql_query . "EXECUTE stmt;";
  
    define("DATABASE_SERVER", "localhost");
    define("DATABASE_USERNAME", "root");
    define("DATABASE_PASSWORD", "");
    define("DATABASE_NAME", "dataR");
  
    $con = mysqli_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME);
    $selected_db = mysql_select_db(DATABASE_NAME, $con);     
  
    $result = mysql_query($sql_query);
  
    $temp = mysql_fetch_array($result);
  ?&gt;
  </code></pre>