NEED HELP BADLY!!! Complete & clear guides in setting up php5.4 to run with Ms-Sql server 2008 R2.

Answered NEED HELP BADLY!!! Complete & clear guides in setting up php5.4 to run with Ms-Sql server 2008 R2.

  • Thursday, June 14, 2012 3:21 PM
     
      Has Code

    hi all,

    I have been assigned to build up a website using php5.4(downloaded the software from php.net - php 5.4.4 win32 vc9 x86) to run along with ms-sql server 2008 r2. Im gonna develop the website using my laptop (windows 7 professional edition, 32 bit). I have installed iis7 too on my laptop to serve as the web server for building and testing on the webpage. While for the ms-sql server 2008r2, it has been running all these while using for building programmes  that runs with c#.net, and i assume there is nothing need to be changed for the sql server in this matter. Besides that, the ms-sql server 2008 r2 native client is already installed beforehand too. I'm all new to php coding and therefore i really need a clear guideline on my problem im facing now. 

    Basically, I have searched through the internet for info on setting up the php 5.4 to run along with the mssql server 2008 r2 by doing the following steps :

    1. downloaded the php software and unzip all the files into C:\php, and rename php.ini.production to php.ini.
    2. downloaded the SqlServerDriverForPhp.exe (sqlsrv30.exe is the file downloaded when i did a google search on that), extract the
        files(php_sqlsrv_54_ts.dll and php_sqlsrv_54_nts.dll) to C:\php.
    3. Copy the php_sqlsrv.dll and php_sqlsrv_ts.dll files to the C:\PHP\ext\.
    4. open the php.ini and goto the Extension section to add in the line Extension = php_sqlsrv.dll
    5. goto Start menu of win7, and click Ok on iisreset at the Run command.
    6. create a simple php file at -  C:\Inetpub\wwwroot\testphp.php with the following codes in this file :
        <html>
        <body>
        <?php  phpinfo();  ?>
        </body>
        </html>
    7. run the testphp.php file using firefox and chrome with the url http://localhost/testphp.php. Instead of getting the phpinfo details page, I have
        received the following error message :

    PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:\inetpub\wwwroot\testphp.php on line 7

    Someone please help me out on this as I really have no idea where has gone wrong on the settings which i have done here :((

    Thanksssssssssss

    From the very confused Baygal >.<



All Replies

  • Thursday, June 14, 2012 4:31 PM
     
      Has Code

    Hi Baygal

    Thanks for the detail in your question, it makes it easier to answer.  There are a few different points to look at...

    1. date timezone warning message:

      The error (warning) you are seeing is not a big problem - you just have to add/edit this line in your php.ini file:

      date.timezone = "America/Los_Angeles"

      This is an example, I'm just guessing where you are - select your real timezone id from this page:
      http://www.php.net/manual/en/timezones.php

      Then do iisreset again.

    2. Your phpinfo file does not need any HTML in it - this is all that's needed:
      <?php  
      phpinfo();  
      ?>
      The function phpinfo() writes a full HTML page on its own.

    3. Regarding SQL Server driver - there is *no* official version from Microsoft that works with both PHP 5.4 and SQL Server Native Client 2008 r2.  It looks like you have IIS 7.x so your version of Windows is capable of running "SQL Server Native Client 2012", which you can download and install from here: http://www.microsoft.com/download/en/details.aspx?id=29065 (search the page for "Native Client").

      Then select the correct driver extension for PHP - for your system, the setting for php.ini is probably going to be:
          extension=php_sqlsrv_54_nts.dll
      which will only work after you've installed the Native Client 2012.

      You can install any number of Native Client versions simultaneously, there is no need to uninstall 2008 r2.

      If for any strange reason you cannot install the 2012 Native Client, see my blog here for a custom version that works with PHP 5.4 and Native Client 2008: http://robsphp.blogspot.co.uk/2012/06/unofficial-microsoft-sql-server-driver.html

    Good luck.


    Rob

  • Friday, June 15, 2012 2:29 AM
     
     

    Hi Rob,

    I have tried to change the date.timezone and the phpinfo() page is up!!! (YAY!!! :)) ).

    However, I still have another inquiry on how do I find out if my Ms-Sql 2008 R2 is able to run along with the PHP5.4.4? Is there a specific coding which I can actually test it out if the both of them are able to work along?? :)

    Again, THANK YOU! :D

    Baygal

  • Friday, June 15, 2012 8:24 AM
     
     

    Hi, well done on progress so far...

    The SQL driver for PHP 5.4 does not work with Native Client 2008.

    You should just go ahead and install the Native Client 2012.

    Native Client 2012 will not harm your computer, it won't break any existing software, and it only takes a moment to install.

    Although its name contains '2012' you can still connect to SQL Server 2005 and 2008 with it.


    Rob

  • Sunday, June 17, 2012 9:46 AM
     
     

    Hi Rob,

    I have installed the Native Client 2012 now, is there anyway for me to test out and confirm that both the php and the sql server are working along correctly? :)

    Thankssss

    Baygal :)

  • Sunday, June 17, 2012 11:31 AM
     
     

    Hi,

    That's great, run your phpinfo() page, and there will be a section titled 'sqlsrv'.  If you search the page for 'sqlsrv' and find it, the driver is ready to go!


    Rob

  • Tuesday, June 19, 2012 2:07 AM
     
     

    Hi Rob, 

    i have tried to run the phpinfo() and found nothing on sqlsvr but the section called mysqlnd. Is the mysqlnd refers to MySql?? But I dont have the mysql running on my computer :/

    Please help me out on this , i cant find anywhere on what has gone wrong.

    Thanksss  >.<

  • Tuesday, June 19, 2012 11:07 AM
     
      Has Code

    Hi Baygal,

    You can ignore the section for mysqlnd, it is an optimised driver for MySql and it's built into PHP, so always there.

    You said you can't find "sqlsvr" - is that a typo?  It should be "sqlsrv".

    If "sqlsrv" is not showing in phpinfo(), look at your php error log file.  To find out where your error log is stored, it is in php.ini:

    // example lines from php.ini:
    log_errors = On
    error_reporting = E_ALL error_log = "C:\PHP\errors.log"
    The error log should contain a message for each extension that could not be loaded.  Could you let us know if you see any messages about the sqlsrv extension?



    Rob

  • Monday, June 25, 2012 1:16 AM
     
     

    Hi Rob

    Sorry, yes, that was a typo :)

    When I checked in my php.ini file, I couldn't find the exactly same line as in your example, all I found is just a few lines which have been set as comment :

    ; error_reporting
    ;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
    ;   Development Value: E_ALL
    ;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

    Please help on this.

    Thankssssss

  • Monday, July 16, 2012 12:04 PM
     
     

    Any solution on this?? I am facing the same issue.

  • Monday, July 16, 2012 6:52 PM
     
     Answered

    Baygal,

    What driver file are you loading? It looks like you're renaming the files when you extract them, which could be cause for error. Could you please re-extract the files without renaming them, and load them into your php.ini as-is. The one you're looking for is php_sqlsrv_54_nts.dll. Also, make sure there are no other references to any other SQLSRV drivers in your php.ini.

    Additionally, what is the architecture of your Windows install (x86 vs. x64)? Which SNAC 2012 package did you download?

    There is a related thread which you may find useful, also: http://social.msdn.microsoft.com/forums/en-us/ssdsgetstarted/thread/e0afb3ce-d522-40db-b767-c4eea347e1fd/

    Finally, you can use the Web Platform Installer to simplify the installation and configuration of PHP and the SQLSRV driver: http://www.microsoft.com/web/platform/

    Thanks,

    Jonathan


    This posting is provided 'AS IS' with no warranties, and confers no rights.