Note that the function takes three mandatory parameters: the data source name, username and password. The odbc_connect() function is used to connect to an ODBC data source. The script connects to MySQL database and fetches all records from a table: With our ODBC drivers, you can access various data sources and retrieve tables and fields from a database.īelow is a sample PHP script for accessing MySQL via ODBC. You can establish a connection to them using ODBC interface. PHP-based projects usually require a data storage, whether a traditional database or a cloud-based database. You can use functions like odbc_exec() to prepare and execute SQL statements against any databases like MySQL, SQLite, PostgreSQL, etc. ODBC drivers are connectors that make PHP development database agnostic - your software written in PHP will function with any vendor's database management system. PHP is one of the most popular programming languages for website development. Please help. Connecting to MySQL from PHP using ODBC Driver for MySQL If I try to connect to MYCOMPUTER64 in that same script, I get the "architecture mismatch" error listed above. If I try to connect to MYCOMPUTER in that script I linked to, I get that big scary 500 error. There is a System DSN set up called MYCOMPUTER64 (set up with the 64-bit ODBC Manager).There is a System DSN set up called MYCOMPUTER (set up with the 32-bit ODBC Manager).There is a database called MyDatabase (again, the name is actually different).The default SQL instance is called MYCOMPUTER\SQLEXPRESS.MYCOMPUTER has 64-bit SQL Server Express 2008 installed.MYCOMPUTER has PHP 5.3.1 installed (32-bit) handled through FastCGI.MYCOMPUTER is running 64-bit Windows 7 Ultimate with IIS 7.5.My computer is called MYCOMPUTER (not really, but think of it that way).I've changed the name of the connection to "MYCOMPUTER," changed the name of the specific database/catalog to "MyDatabase," and hidden the password, but made no other changes. I also have the (very basic) PHP script shown here. A copy of the error trace it provides can be found here (IE-only). One poster suggested I check the Event Log, but that shows nothing, and another poster suggested I enable Failed Request Tracing, which I have done but I'm not so sure it provides anything telling. UPDATE: I'm starting a bounty because I really need to get SQL Server and PHP talking to each other soon. ![]() Help! Connecting to a SQL Server should be a relatively simple and straight-forward task, so what do I need to do to get things working? Now my PHP script does the equivalent of segfaulting because it's apparently getting hung up on this 64-bit ODBC driver. Instead, I am getting a seemingly much more evil error, namely this one:īefore I was just getting a simple PHP exception. I am no longer getting that error I listed above. (Plus I absolutely loathe the fact that the trilogy sites are split in the first place, but that's another story.)Īnyways, after setting up the data source using %windir%\sysWOW64\odbcad32.exe instead, I seemed to make some progress. In retrospect I probably should have asked that here, but I got my answer so I don't care. ![]() I asked about this on Stack Overflow and got an answer. At first I had trouble getting it to connect, because even after I added my local SQL server as a server DSN in the ODBC manager, I kept getting this error: The specified DSN contains anĪrchitecture mismatch between the Driver and Application I've been trying to make PHP connect to my local installation of SQL Server 2008 Express over ODBC using ADODB. ![]() I'm running PHP 5.3.1 on IIS 7.5 on Windows 7 Ultimate 圆4.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |