PDA

View Full Version : PHP + MS SQL Server - how to make it work??? HELP!!! :(



phinix_mike
10-27-2009, 07:52 AM
OK. I hope this is right place to ask.
Guys, I'm totaly noob in this stuff, so please be patient:)

I have a Windows 2003 server with MS SQL 2003 server on it.
I also have a php webpage and want to make it work with database on SQL server.
HOW CAN I DO IT? :(

Please take me through all the stages slowly cause I may lost somewhere and don't know what did wrong.

First of all, need to install PHP on my pc and on server, is that correct?
IIS server is configured correctly, cause it has some website already there which is running (ASP, not php) so I believe I need to work on sth else now?

There's php file, there is also html page with from that runs that php file. However nothing happens after I clik submit button. It asks if I want to open input.php file, when I click OK, nothing happens.. what is wrong here?

rogard
10-27-2009, 08:30 AM
I realize you want to use php and mssql, however why not try out WAMP first (http://www.wampserver.com/en/)

Get used to things with that, then look at using php with iis and mysql.
Then php iis and mssql.

If you do it in stages you will learn more about how they fit together..and you get more experience :)

Remember to stop/uninstall/change port of iis before installing or the ports will clash.

phinix_mike
10-27-2009, 10:22 AM
I have to use our server, not anything else. I used to use mysql and apache, that was easy, but for some reason this cannot work with IIS:(

rogard
10-27-2009, 11:58 AM
Have you got an "hello world" app working with iis?

phinix_mike
10-28-2009, 12:54 PM
guys, after another day working on this to make it work I have some new conclusions.

Hello world and other stuff works fine. I checked with other, default php website from pub folder and it works.
Thing is for some reason server doesn't know what to do with mssql command. When I use mssql_connect () in my php file it doesn't do anything. Getting standard http 500 error, that page cannot be displayed.
When I change it only to odbc_connect(), it gives my my error message from my php file and odbc_error() info which is IM002.
I believe this is connection error, or incorrect driver..
Things is - this is Windows server 2003 with MS sql server 2003 installed. IIS seems to be configured correctly. I also installed PHP on C drive of the server and changed ini file to use mssql, updated system PATH etc...
Now, when I add new website in IIS manager and put those html and php file in it, it doesn't work.
What is missing here? Tell me if you need more info about the whole system or any other details to help find a problem...

ben0
10-29-2009, 11:31 AM
I might be miles of base here, just quickly read the thread but try:-

echo mssql_get_last_message();

After your myssql_connect statement. This will report the last error received from the MS Sql server. You could also check you php has mssql compiled in correctly by adding:-

phpinfo();


ben0.

phinix_mike
10-29-2009, 01:11 PM
I might be miles of base here, just quickly read the thread but try:-

echo mssql_get_last_message();

After your myssql_connect statement. This will report the last error received from the MS Sql server. You could also check you php has mssql compiled in correctly by adding:-

phpinfo();


ben0.

Thanks, I will try that tomorrow at work.
Do you know where could I find error log in IIS server? Is it in default event viewer of the OS or somewhere else? I couldn't find any in IIS manager...

ben0
10-29-2009, 02:34 PM
No worries mate, I hope it helps.

IIS Log files are stored in 'c:\windows\system32\logfiles\'. But these only pertain to logging for each website or virtual host. I think the rest are contained in the Application log. You could also turn on error logging in your php script:-

ini_set('display_errors', 1);
error_reporting(E_ALL);

GL dude ;-)

DeanB
11-05-2009, 03:02 PM
Definitely run a page with just phpinfo(); and check to see if its even loading the right module. Also once you get it working, look at PEAR for its DB library which is great for cross platform coding.