Is file_get_contents multiple lines?

Does file_get_contents support line breaks? I thought it happened, but I tried this:

if($conn){

    $tsql = file_get_contents('scripts/CreateTables/SLR05_MATCH_CREATETABLES.sql');

    $row = sqlsrv_query($conn, $tsql);

    print_r(sqlsrv_errors());

}

      

The errors I'm getting are that SQL Server is complaining that there is incorrect syntax. I get the same errors when I run SQL Script without any line breaks, which suggests file_get_contents is removing them?

When I normally run the Script (open the file in SQL Server Management Studio) and execute it, it works fine.

So, is there something I can use that supports line breaks, etc.? Or is there a different issue when using queries from a file using Microsoft's SQL Server PHP Driver?

Thanks everyone for the help

+2


a source to share


1 answer


file_get_contents () saves the file. Perhaps your file contains the wrong "type" of line breaks? Linux-vs-style windows?



Also, I'm not familiar with sqlsrv_query () ... can it be used to run multiple queries (like a script can be) or only single queries one at a time?

+3


a source







All Articles