0

Good day I want to host my website that is written in php in IIS I have already installed php on my server and added the dll file but I'm still getting the HTTP 500 error when loading the website.

I'm using the following:

php 5.6.20 in my php.ini file I added

extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll
extension=pphp_pdo_sqlsrv_56_ts.dll
extension=php_sqlsrv_56_ts.dll

and added the dll files in my ext folder and restarted the server

I want to query a database from the server this is my connection to the database:

        $servername = "TEST\TEST08";
        $username = "Admin";
        $password = "admin";
        try {$conn = new PDO("sqlsrv:server=$servername;Database=My_Db",
        $username,$password);
            // set the PDO error mode to exception
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            echo "Connected successfully"; 
            }
        catch(PDOException $e)
            {
            echo "Connection failed: " . $e->getMessage();
            }

         $getdrop = conn->prepare($myQ);
         $getdrop->execute();

please assist

I have the logs and I got the following errors in my logfiles:

[10-May-2016 10:54:42 Europe/Minsk] PHP Notice:  Undefined variable: conn in C:\test\index.php on line 43
[10-May-2016 10:54:42 Europe/Minsk] PHP Fatal error:  Call to a member function prepare() on null in C:\test\index.php on line 43
[10-May-2016 10:54:43 Europe/Minsk] PHP Notice:  Undefined variable: conn in C:\test\index.php on line 43
[10-May-2016 10:54:43 Europe/Minsk] PHP Fatal error:  Call to a member function prepare() on null in C:\test\index.php on line 43
Christiaan
  • 59
  • 7
  • 2
    `new PDO("sqlsrv:server=$servername;Database=My_Db,` missing a quote `"` in the end there, before the comma. The highlighting shows this easily, which is why you should use a text-editor that supports this. – Qirel May 10 '16 at 07:35
  • @Qirel I fixed it and still getting the same error – Christiaan May 10 '16 at 07:37
  • 1
    Then check your logs and figure out what the exact error-message is. – Qirel May 10 '16 at 07:38
  • 1
    Actually, `$getdrop = conn->prepare($myQ);` missing `$` in front of `conn` – Qirel May 10 '16 at 07:38
  • Add missing quote into `$conn` row and change `$servername = "TEST\TEST08";` to `$servername = "TEST\\TEST08";` Also `$getdrop = conn->prepare($myQ);` must be `$getdrop = $conn->prepare($myQ);` – mitkosoft May 10 '16 at 07:40
  • I changed it and now im getting the following error : "[10-May-2016 10:49:19 Europe/Minsk] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The SELECT permission was denied on the object 'Class', database 'My_Db', schema 'dbo'.' in C:\test\index.php:44 Stack trace: #0 C:test\index.php(44): PDOStatement->execute() #1 {main} thrown in C:\test\index.php on line 44" – Christiaan May 10 '16 at 07:52
  • so that is just the rights I have with the user – Christiaan May 10 '16 at 07:52
  • @mitkosoft I have the user sorted now Im getting the following errors:[10-May-2016 10:54:42 Europe/Minsk] PHP Notice: Undefined variable: conn in C:\test\index.php on line 43 [10-May-2016 10:54:42 Europe/Minsk] PHP Fatal error: Call to a member function prepare() on null in C:\test\index.php on line 43 [10-May-2016 10:54:43 Europe/Minsk] PHP Notice: Undefined variable: conn in C:\test\index.php on line 43 [10-May-2016 10:54:43 Europe/Minsk] PHP Fatal error: Call to a member function prepare() on null in C:\test\index.php on line 43 – Christiaan May 10 '16 at 07:59

0 Answers0