Jump to content

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

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.