PHP pdo_odbc query fails on Windows - php

Please bear with me.. I am not entirely sure how to ask this question. I hope someone catches on.
I do my PHP (7.4 and 8.0) programming in FreeBSD, connecting to Windows based SQL servers using PDO_ODBC. In FreeBSD, I successfully use FreeTDS to pull data over ODBC and everything works.
What I am developing is meant to run on XAMPP or WAMP (or any similar stack) on a Windows Server of recent flavor, but when I copy the PHP code over, my query fails. I have set up a 64bit DSN which successfully connects to the target database and I can run queries against the database - at least in simple terms. The code I am trying to migrate contains a fairly complex query and running it on this platform return 0 data to the PDO. It runs fine in SQL Management Studio.
So the question is very open ended, but for now: Why or what?

Related

Does php 5.6.6 work with mysql 5.6.23?

Or is php 5.4 only compatible with mysql? I've been having some problems getting my php to work with mysql.
I'm using PHP 5.6.6, Apache 2.4, MySQL 5.6.23. My PHP and Apache work just fine. I created a website using CSV. I wanted to learn how to use MySQL, but I was having problems trying to get MySQL to work with my PHP. Now, I have never take any courses on MySQL nor have I ever used. The only thing I have done with MySQL is install it from the community tab from the MYSQL download page. I followed all the instruction and set my file path to be C:\mysql, and my data path to be C:\mysqldata, but I don't know, why it doesn't seem to work with my php when I try to connect. Is there another step I have to take to connect? I know a lot of people use WAMP, which is something I might look into if I don't get this working, but If there's anyone who has installed all three (apache php and mysql) sperately, know what my problem might be, I'll really appreciate it.
PDO works on all PHP versions 5.1+, which is the preferred method to connect to MySQL.

CI and SQL Server from Linux

I’m actually developing a CI app in my developer machine with Windows and XAMPP, using de sqlsrv driver to connect to the MS SQL Server 2008 database.
But the final server machine is an Ubuntu server, and trying to run the app from there doesn’t work because of the sqlsrv driver not installed in the server.
I tried the mssql driver and the app starts to load but it ends with SQL queries errors (SQL queries previously tested and working).
What do you recommend?
Is it possible to connect from Linux/PHP/CI to SQL Server 2008? If there is a way, will it be as fast as running on Windows? It will be compatible with CI Active Record?
Is it better to create a new Windows server?
Thx
I would say that you should develop on whatever you deploy to so if you will stick to dev on windows, deploy to a windows box.
If you do want to get it working, I have seen a ruby app talk to ms sql 2005 before, you need to make sure you have FreeTds working, this looks like a good walkthrough:
http://php.net/manual/en/mssql.setup.php
If you are using sql 2008 there are some features which probably are not in sql 2008 like table valued parameters which FreeTds won't support so it might be not working because you are trying to use something it can't do - have a look at the query that fails and see what types it has and the types of the responses, if anything is new to sql 2008 it might not work.

Connect to a remote Windows Sybase database from Ubuntu via PHP

Ubuntu 12.04 LTS Precise
I'm trying to use PHP to connect to a remote Windows Sybase database. Let us assume Windows 7 Enterprise SP1. I'm currently doing this in PHP:
$db = sybase_connect("10.1.208.111", "$user", "$pass");
And I'm getting an error of:
Warning: sybase_connect(): Unable to connect to server: 10.1.208.111
I understand that the server I'm connecting to (10.1.208.111), needs to be in the interfaces file. I'm trying to figure out where that is, or even if I have one on the Ubuntu server (I'm still new to linux itself). I read that the path for the file is located in the SYBASE environmental variable. I don't know where that is either. Can anyone shed some light? I can offer more information if you need it, I just don't know what you need right off the bat.
PS: The windows machine has Micros RES installed on it. That's the database I'm trying to pull data from. Not sure if that matters.
The default installation directory for Sybase ASE in windows is C:\sybase, so your interfaces (interfaces.ini) should be located there.
For SQL Anywhere, the interfaces file is called SQL.ini, and it's location varies, but you should be able to do a search of your system drive to find it.
For SQL Anywhere you probably want to use the PHP apis that are provide by SAP Sybase. The SQL Anywhere documentation is a pretty good place to start, as it covers all the pieces that need to be installed to get SQL Anywhere to talk to PHP.
SQL Anywhere 11: SQL Anwhere PHP API
You may also be able to find good information over at the SAP Community Network site for SQL Anywhere.

Access DB PDO not working in Windows Server x64 edition

Guys I am really stuck up here with this Access DB. I made a php application for a company, the record exporting to MS access in the web application is giving me headache.
I installed Xampp 1.8.1x32 and MS office 2010 32bit professional in their Windows 2008 64 bit version server, everything is working fine! I enabled extension=php_pdo_odbc.dll in the php.ini and I tried to export data from mysql to accdb file using php PDO, but it's not inserting data into the accdb file.
I even tried adding a system DSN to the accdb file in both ODBC 64bit and ODBC 32bit by installing "Access Database Engine x64" and "Access Database Engine x32", but still out of luck. The same mysql to accdb data exporting is working fine in my win7 x64 and ms office 2010 x32 even without installing access database engine and without setting DSN!
Kindly let me know whether there is some other way out to insert data into accdb using PDO in Win 2008x64 server edition. Should I install any special access database edition in win 2008, or should I enable something to make it work?
Sorry for this lengthy and twisted post :p I didn't find solution anywhere else in the internet. Kindly help!
Update: There is no PDO or php errors displayed. just it's not working!
I experienced the same problems. I was able to read and display records but INSERT had no effect, no error was thrown either. The thing is, I kept trying to execute an SQL statement with the values already filled out. Once I tried the prepare and execute statements with actual parameters it did work. I have no idea why it behaves this way but it seems like you can't directly execute INSERT statements?
Btw I previously tried 'prepare - execute' with no arguments as well ( as the data was filled out in the query already ). Glad it only took me 3 hours of trial and error! :(

How to migrate from my WAMP environment to using MSSQL?

I have on my local PC installed WAMP environment (using WampServer OS).
Now I would need to change one script from working with MySQL to MSSQL.
I have no idea at all how to proceed, where to download MSSQL, how to install it and how to connect with PHP?
Thank you very much
Download mssql express http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx
Familiarize yourself with one of the great database abstraction layers, for example PDO http://www.php.net/pdo
Refactor your code to use the database abstraction layer
You may need to rewrite the mysql specific things to "standard" SQL
Start by getting Sql Server working. If you are using an old copy of Sql Server (pre 2005) you will need to make sure ntwdblib.dll is present in your System32 directory, and removed from your PHP dll directory (ntwdblib.dll is installed with the enterprise tools, so you may have to install them on your PHP box as well). Once you have Mssql querying properly, start finding where Mssql differs from MySql in your code.
A couple of tips:
The ntwdblib doesn't accept long strings (I think it is limited to 4k, but don't quote me on that). You have to use Stored Procs if you are trying to process a string longer than 4k.
Try to use Sql Server 2005 if you can (see above), the ntwdblib.dll is ancient and has numerous issues.
The PHP site is your friend for mssql.

Categories