rich11 Posted October 19, 2007 Share Posted October 19, 2007 Hello... I am new to php and not sure how to get php to work with MS SQL. Do i need to set up a DSN??? And then use this code to contact the database?? $host="localhost"; $username="root"; $password="root"; $dbName="clients"; Thank you, Rich Quote Link to comment https://forums.phpfreaks.com/topic/73958-how-do-i-get-php-to-read-a-table-from-ms-sql/ Share on other sites More sharing options...
niwa3836 Posted November 11, 2007 Share Posted November 11, 2007 Rich, i am new too, but have this working. You are missing the bits of code that do the $conn=odbc_connect and a few others which I am sure you know just didnt put in the forum (I presume that you have been to www.php.net and searched on this command, does show good examples etc). The bit that isnt shown is the DSN, which you do need. So install SQL, any machine. Best run mixed mode Create Datbase, and or table Go to machine where php, control panel, admin, odbc datasource create a SYSTEM dsn. give a name (database name) ensure you say where SQL server is (if local give local NAME) (ping to check) Change the database (tick box) as required Enter sa and sa password TEST (should say ok) then save try changing localhostname to the IP address of the server as well to make sure that isnt a problem. Hope this shorthand makes sense Quote Link to comment https://forums.phpfreaks.com/topic/73958-how-do-i-get-php-to-read-a-table-from-ms-sql/#findComment-388992 Share on other sites More sharing options...
victor_ar Posted November 21, 2007 Share Posted November 21, 2007 Hello, I used mssql_connect and other function like my the mysql_functions. For example: $connection = mssql_connect("Server","user") // include your password if needed mssql_select_db("table_name", $connection) $result = mssql_query("select * .......", $connection) while ($row = mssql_fetch_array($result)) { // for example echo $row["field_name"] } Quote Link to comment https://forums.phpfreaks.com/topic/73958-how-do-i-get-php-to-read-a-table-from-ms-sql/#findComment-395894 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.