Jump to content

ASP db Connection Code??


Round

Recommended Posts

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 = adocon
rs.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
Link to comment
https://forums.phpfreaks.com/topic/28835-asp-db-connection-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.