tress Posted August 13, 2007 Share Posted August 13, 2007 Hi, First post here and very new to php so please nothing to complicated. I have installed the latest edition of PHP on my server using the Installation kit I am running IIS Version 6 and SQL Server 2000 I have edited the php.ini file to allow this connection and made sure that all relevant files are in the right place. I have a very basic piece of php <?php // connect $cs = mssql_connect ( "localhost", "sa", "password" ) //or die ( "Can not connect to server" ); // select mssql_select_db ( '[test]', $cs ) or die ( 'Can not select database' ); //query $sql = "SELECT * FROM [all]"; $r = mssql_query ( $sql, $cs ) or die ( 'Query Error' ); // loop the result while ( $row = mssql_fetch_array ( $r ) ) { /* do stuff */ } ?> The problem is when I run this script I just get a blank page, I have saved the file as a php but it doesn't seem to be doing anything. Have I done something really stupid and I am just not seeing it. Thanks Phil Quote Link to comment https://forums.phpfreaks.com/topic/64652-php-connection-to-mssql/ Share on other sites More sharing options...
amylou Posted August 13, 2007 Share Posted August 13, 2007 is [test ]the name of your database? and if so is [all ] the name of a table in your database? if they are the same then that is your problem Quote Link to comment https://forums.phpfreaks.com/topic/64652-php-connection-to-mssql/#findComment-322338 Share on other sites More sharing options...
tress Posted August 13, 2007 Author Share Posted August 13, 2007 Hi, Thanks for the reply, yes TEST is the name of the database and [All] the name of the table. Thanks Phil Quote Link to comment https://forums.phpfreaks.com/topic/64652-php-connection-to-mssql/#findComment-322346 Share on other sites More sharing options...
amylou Posted August 14, 2007 Share Posted August 14, 2007 what if you tried to change the mssql to mysql. i don't know if that will work. you might also want to put in what the code is supposed to do in the while statement that might help you Quote Link to comment https://forums.phpfreaks.com/topic/64652-php-connection-to-mssql/#findComment-323163 Share on other sites More sharing options...
tress Posted August 14, 2007 Author Share Posted August 14, 2007 Hi, Thanks for the reply, I am not using MySQL but an SQL Server so I wouldn't of thought chaning that would of made any difference, might be my bad coding but I thought the end piece of the routine would just bring back the row select. Also, at the top of the code it says that the connection should die if it cannot log onto the database, I have put some bad data into here before and do not get that message so it looks like the code isn't even trying to talk to the data base i.e. I have installed PHP wrongly. Thanks again for the help, any more advice is greatly appreciated. Thanks Phil Quote Link to comment https://forums.phpfreaks.com/topic/64652-php-connection-to-mssql/#findComment-323254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.