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.
Related
I am changing my hosting provider and migrating from cPanel to Plesk. Everything is nice and I am exited but I can't get old PHP scripts working which still use MySQL instead of MySQLi or PDO.
Plesk lets different accounts or domains use different versions of PHP. Fortunately even older versions that still recognize MySQL are available (5.4, 5.5, 5.6) and I have actually managed to make one of my domains to use PHP 5.6 but although it works there, MySQL is still not available. MySQLi is working with PHP 5.6 but all point of downgrading PHP was to get MySQL working. It simply complains: 'Call to undefined function mysql_connect()'.
As far as I can see mysql extension is installed. phpinfo() shows sections of mysql and mysqli and mysqlnd and even pdo_mysql. mysql.so is there at /opt/plesk/php/5.6/lib64/php/modules.
I have tried all the options in Plesk and I have edited the ini files (extension=mysql.so) but no progress. I have spent all day already. Have also tried different handlers.
One thing that I have noticed is on the phpinfo() page. 'Configure Command' section contains among the other strings, the following: '--without-mysql'. I don't see a way in Plesk to remove this. And I don't see a way to change configure options for PHP. Is this the reason why mysql_ functions don't work? How to solve this? I got it working easily with cPanel but Plesk is new to me and Google has not been helpful today. Please advice!
I am still new to php and linux but i try to give you all information I know.
We got a PHP web application using pear and smarty. It's runing on PHP 4 on a Linux system and with XAMP and PHP5 on my PC. I am trying to move the application on a new server with PHP7 and updated PEAR and all extensions (it's the same version as on XAMP), but all I get is: DB Error: extension not found.
I tried to find a solution but wasn't able to find anything which could help me.
The database we are using is a normal mysql database.
I'm not sure if there is still a path missing or what went wrong.
Maybe someone of you got a clue what the problem could be.
It sounds like your very old PHP4 code is using the mysql_ database extension?
If so that extension has been deprecated for years and was completely removed from PHP7. You wont be able to move that code to any version of PHP higher than PHP5.6 and even trying to do that you will almost definitely come across lots of other incompatibilities
I suggest you read http://php.net/manual/en/migration70.php in the menu on this page there is a section on migrating from all sorts of versions of PHP.
You will have to work out how far up the migration levels your code will actually move without major amendments. I would guess, not very far!
I generally use linux servers and program in PHP (plus other associated technologies) with mysql databases. A client has existing ASP sites using MSSQL databases on a Windows server and wants some new sites created on their server using their MSSQL database as the main data source. I have used ASP in the past but much prefer PHP so would rather use this.
I just wanted to confirm that i'm right in saying as long as the server has PHP installed (which it does) then there's no reason I can't create a PHP site on the Windows server and just use different connectors to connect to the MSSQL db (rather than what i would usually use for connecting to a MYSQL db). Presumably (other than the different connect/query code) this would work in pretty much the same way as with a linux setup with mysql and i could then code the site in PHP but use their existing datasource?
I would be extremely grateful if anyone could confirm i'm right in saying this and if there's any other issues that might cause any problems?
Thanks so much for your help as ever,
Dave
You can enable MSSQL support in PHP on Windows. The default Windows PHP install has the php_mssql.dll extension commented out in the php.ini file. Uncomment that line, restart Apache, and it should work.
There is a supporting DLL called ntwdblib.dll that you may need to find a replacement for, as the version included with PHP may be outdated and won't work with newer versions of SQL Server. (I had this problem when setting it up.)
There are two different libraries to connect to SQL Server from PHP:
The legacy mssql extension, which has been discontinued on Windows
Microsoft's sqlsrv extension, which only works on Windows
I've basically worked with the second one and I can say it's a very interesting product. It's robust, it has a very nice interface and it's totally up-to-date. But what I like most is that it has very nice features. E.g.:
It can return dates as PHP DateTime objects
It provides a PDO driver
The only drawback of using SQL Server is that there isn't an easy way to write a cross-platform app but I understand it isn't problem in your case.
Yes, it is rather straight forweard.
You need to have the mssql library activated in php.ini. Which can be troublesom.
MSSSQL docmentation
In my application there are two PHP are available.
1) PHP 5.1.6
2) PHP 5.2.6
Currently I am using PHP 5.2.6 version in my application. Also I'm using PHP 5.2.6 database ( phpmyadmin ).
Here my question is I want to use another PHP's database ( phpmyadmin ) i.e. PHP 5.1.6 's phpmyadmin.
I dont know how to do this, Please give me ur suggestions, in which file should i make change for accessing correct database in my application.
Thanks
-Pravin
phpMyAdmin is not a database, but a front-end for a DBMS like MySQL. Your scripts in PHP 5.2.6 and 5.1.6 are likely using using the same database (MySQL).
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.