Round Posted November 29, 2006 Share Posted November 29, 2006 I am trying to re-write a web site from asp to php and I have come across a piece of ASP code (see below) which I need to replicate so that the news, displays on my php page, but I have no idea how to replicate this in php. I have tried the usual connection method[code]#connect to db $conn = @mssql_connect( "server", "", "" ) or die( "Err:conn"); #select db $rs = @mssql_select_db( "dbname", $conn) or die( "ERR:Db"); #create query $sql = "select * from news"; #exe query $rs = mssql_query( $sql, $conn ) or die( "Could not execute Query");[/code]But it just doesn' work, I think it must be to do with the DSN part in the following asp code??Am I right?asp code:-[code]Set adocon = Server.CreateObject("ADODB.Connection")adoCon.Open("DSN=dbname")set rs = Server.CreateObject("ADODB.Recordset")rs.ActiveConnection = adoconrs.Source = "SELECT * FROM news"rs.Open()[/code] How do I replicate this so that news displays on my php page??Usual asp connection code looks like this:-[code]set con=Server.CreateObject("ADODB.Connection")con.open "PROVIDER=SQLOLEDB;DATA SOURCE=server;UID=username;PWD=password;DATABASE=dbname "set rs=Server.CreateObject("ADODB.recordset")strSQL = "SELECT * from table"rs.Open strSQL, Con,3,3[/code]Which is the equivilent to the standard php method above.Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/28835-asp-db-connection-code/ 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.