0

Hello dear daniweb experts, i was searching over the web and couldn't find any good explenation on how to write properly to a Microsoft SQL server database, so i decided to ask the experts here:

How to properly write to the sql database:
i used this snipped to read:

//Start connection

      $cs = mssql_connect ( 'BETADEV-8752AC8:15779', 'sa', 'cc830522' ) or die ( 'Can not connect to server' );

   
      mssql_select_db ( '[rxjhaccount]', $cs ) or die ( 'Can not select database' );

      $sql = "SELECT * FROM [TBL_ACCOUNT]";

      $r = mssql_query ( $sql, $cs ) or die ( 'Query Error' );


      while ( $row = mssql_fetch_array ( $r ) )

      {

      echo '$row';

      }
	
	echo "All went accordint to plan";
	mssql_close($cs);

but no results ware even displayed.
Here are some screens:

My server:
http://img198.imageshack.us/img198/6293/img1v.png

My Database:
http://img194.imageshack.us/img194/7601/img2zr.png

So my question is how to properly read the values stored in TBL_ACCOUNT under the row "FLD_ID". Thanks in advance:
~Cha0sBG

Edited by Cha0sBG: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rajabhaskar525
0

on line 17 you have "echo $row". I dont believe this will echo the row unless it knows what column to echo. so if you want username it would be

echo $row['username'];
0
<?php
// Create a link to MSSQL
$link = mssql_connect('servername', 'username', 'password');

// Select the database 'php'
mssql_select_db('databasename', $link);
?>

i think connect to sql server use above code.

see this link for more information about microsoft sql server in php.

hope this will helpful to you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.