Hi everyone...
I've been working with ASP for a while, and decided that I'd prefer to work with PHP after looking at the code and how much easier it is to work with.
However, I've been looking for a couple days now to see if there was a way to get a DSN-less connection to a database with PHP.
For example, ASP allows the ability to connect to a database that has not been added to the DSN ODBC of the server using the following code :
<%
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("salesstuff.mdb")
MyConn.Open "Driver={Microsoft Access Driver _
(*.mdb)}; DBQ=" & MdbFilePath & ";"
%>
Is there a way to do something similar in PHP? I ask because I have access to a remote server where I'd like to put a lot of my PHP work, but I don't want to have to pay up the extra cash for them to put my mySQL database in the DSN of the server.
Thanks a lot!
DSN-less mySQL connections?
Moderator: General Moderators
by creating a ADODB-COM-Object (Server.CreateObject) your access-db engine is invoked via mdac.
You can create COM-objects in php/win32 with
$var = new COM($progId);
http://www.php.net/manual/en/ref.com.php
You can create COM-objects in php/win32 with
$var = new COM($progId);
http://www.php.net/manual/en/ref.com.php
RE:
Ok, that answers part of my question, but I still have another issue. The link you posted states:
COM functions are only available on the Windows version of PHP.
Therein lies my problem... the servers in question are Linux servers running mySQL. Is there a way to do this running under a Linux version of PHP? Or would the commands bascally do the same thing?
COM functions are only available on the Windows version of PHP.
Therein lies my problem... the servers in question are Linux servers running mySQL. Is there a way to do this running under a Linux version of PHP? Or would the commands bascally do the same thing?
afaik you depend on odbc when you want to connect to a access-db with php/linux.
But mySQL does not use DSN-strings to connect to the database.
resource mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]])
like
But mySQL does not use DSN-strings to connect to the database.
resource mysql_connect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]])
like
Code: Select all
$conn = mysql_connect('www.where.the.server.is', 'dbuser', 'dbpass');