Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/64652-php-connection-to-mssql/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.