Add MsSQL via PHP INI - php

I just uploaded and overwrote the old php.ini with a new one that was blank and now all my mssql_connect() functions are not working.
What is the commange to enable this again?

Remove the semi-colons ; before the modules for mssql.
Search for ;extension=php_mssql.dll in your php.ini and remove the ; at the beginning. After this, restart the Apache service.

To my knowledge, you'll have to assemble a new php.ini. You can go to http://php.net/downloads.php and download PHP as if you were going to install it. There are at least two version there to start with.

In php for windows are a precomiped php_mssql.dll, in unix/linux you can use mssql module via freetds library, some distributions have compiled it if not you have to compile it manually. if you have doubts about compile ask it in comments.
To enable or disable modules in php ini search the extension keys you look something like
In Unix/Lin:ux
extension=mssql.so
In windows
extension=php_mssql.dll
disabled means the line is not present, or can be commented with a semicolon ; at first.

The PHP distribution on most platforms ships with sample php.ini files named php.ini-development and php.ini-production. If you copy whichever one of these files is most suitable for your environment to php.ini, you will at least be in a known good state.

Related

mysqli extension missing (Windows 10, PHP 7.17, MAMP,)

So I have been searching high and low an answer to my problem. Anytime I go here
http://localhost:8888/phpMyAdmin/, I get this error
So I created a php file with phpinfo() and get this
info.php
So then I go to my file explorer and follow the directory
C:\MAMP\conf\php7.1.7
Loaded Configuration File C:\MAMP\conf\php7.1.7\php.ini
Next I opened the php.ini file in sublime to make some changes (C:\MAMP\conf\php7.1.7\php.ini). I believe all the extensions are located at this directory
C:\MAMP\bin\php\php7.1.7\ext
where I think the php extensions are located at
So these are the changes I make to my php.ini file (removing the ; from the front)
1) ;Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\MAMP\bin\php\php7.1.7\ext\"
2) ; Dynamic Extensions.
extension=php_mysqli.dll
I restart my MAMP server every time I make a change and reset my browser as well. And I still get the same "mysqli extension" missing error
I have even tried adding some environment variable paths.....
added two different environment variables
C:\MAMP\conf\php7.1.7
and
C:\MAMP\conf\php7.1.7\php.ini
Also here is my new_connection.php file and code to connect to MySql
new_connection.php
This is what I get when I run the code (showing that both If statements are failing)
mysqli_init function does not exist,
mysqli extension is not loaded
I found this
https://secure.php.net/manual/en/mysqli.installation.php
which states....
PHP 5.3.0 and newer
On Windows, for PHP versions 5.3 and newer, the mysqli extension is enabled and uses the MySQL Native Driver by default. This means you don't need to worry about configuring access to libmysql.dll.
Which confuses me, because the mysqli extension did have a ';' in front when I opened the php.ini file
I used MAMP with PHP version 8.0.1 and the phpMyAdmin-Page always said that it needs mysqli to work. I searched every folder, commented a lot, always refreshed the server and so on but nothing worked...
... until I changed the PHP version to version 8.1.0 in the MAMP-settings and the extension_dir in the php.ini (path should be something like \MAMP\conf\php8.0.1) (the "extension_dir" should be in line 544).

Installing PHP on Linux and php.ini file

I have installed PHP with Apache 2.2 on my Linux machine and all works fine following guide here
During the installation I had to copy the php.ini-development file into /usr/local/lib/php.ini, the question is why? Why exactly in this directory?
Default locations of the PHP configurations vary greatly by distribution. In any case, phpinfo() will allways tell you where is looks for your configurations.
So, create file with extension ".php" in your webroot and past this into it:
<?php
phpinfo();
Also, the default php.ini files contain plenty od usefull comments. Just read them and change what you need. Differences between dev and prod environments are usually only the verbosity. They show and log different ammounts of errors. Production usually shows no error at all.
(Debian and many other distributions put the PHP config into /etc/php5. This is actually the most reasonable place for configurations, but stick with what your distribution uses.)
The document you link to says this
You may edit your .ini file to set PHP options. [...]
If you instead choose php.ini-production, be certain to read the list of changes within, as they affect how PHP behaves.`
Have you tried something like
vi /usr/local/lib/php.ini
to see what's in it?
Maybe you need to read http://www.php.net/manual/en/configuration.file.php
You copied a default PHP.ini file, php.ini-development, to the standard 'php.ini' file in the location '/usr/local/lib/' the guide http://www.php.net/manual/it/install.unix.apache2.php
expected the php.ini file to be.
The php.ini file is a configuration file used by PHP when it is launched (runtime)

Php.ini production vs development

I'm using XAMPP to develop on my localhost. I would like to remove the PHP notices and keep only the warnings. I know this is done through the php.ini file, however I'm having trouble locating it. I followed the path in phpinfo() and it led me to /xampp/php. Inside this folder are two php.ini files: one for production and one for development. I have set them both to the error reporting level I'd like, however I still receive notices which makes me believe that neither of these actually control error reporting. I'm using the latest version of XAMPP. So I guess my question is where is the true php.ini and what are these two other versions?
As of PHP 7 the regular php.ini file was removed and added with php.ini-production and php.ini-devlopment. In PHP's installation text file they state, "We advise you to use php.ini-production, because we optimized the default settings in this file for performance, and security."
So in short use the php.ini-production
First, make sure you're editing php.ini, not php-development.ini or php-production.ini or anything BUT php.ini. After that, ensure you restart your Apache server or your changes won't take effect.
Also, check out ini_set for setting ini values at runtime.
I had this confusion, in my computer, the php.ini file didn't appear with the .ini extension name visible - it was just php , and in the type column, it has the value 'configuration settings'
I downloaded php-8.1.0 from official website. php.ini or configuration settings file is not present in it. Instead it has been replaced by two files i.e. php.ini-development and php.ini-production.
My requirement was to edit the php.ini file in order to enable pgsql extension. Alas! there were not one but two .ini files. Being new to php, I made changes to both the files but it didn't worked.
After doing some research, I came to know that in the recent versions of php (not sure from which), user is provided with two .ini files. As name suggests, php.ini-development contains settings suitable for development environment and php.ini-production contains settings suitable for production environment. As per your requirement, you need take backup of anyone of the file and rename that file to php.ini. In this file you will need make required changes for your php environment.
If you compare the two files using tools such as diff-merge, you will get more in-depth understanding.
php.ini.development and php.ini.production are entirely different from php.ini.
the problem is that in the php folder the required php.ini is not marked along with its extension ( .php). Only php is written.Check the properties of the file 'php' of "*configuration settings*" type.it must be .ini,This is the exact file which manages error reporting.
In XAMPP version 1.8.1 php.ini file located at \xampp\php\php.ini modify line 922 upload_max_filesize = 2M
Note: 2M means 2MB, so change to 10M for 10MB file upload. Also note that php.ini-development and php.ini-production are different files from php.ini.
My issue is that I was editing the php.ini-production and overlooked the standard php.ini file.
I edited the php.ini file by adding extension=php_odbc.dll and it fixed the error.
PHP 5.3.0 has significantly improved performance and parsing of INI files, and adds several new syntax features.
The standard php.ini files have been re-organized and renamed. php.ini-development contains settings recommended for use in development environments. php.ini-production contains settings recommended for use in production environments
The PHP.ini file is still there, only it doesn't include the extension .ini, the extension has been removed. You will notice two file name php, one is application file another is configuration setting when you open configuration setting in notepad you will notice that it has ini extension. so the php configuration file is ini file.

After I configure my php.ini file to load the MySQL module, it doesn't appear in phpinfo() and I can't call to MySQL functions

sorry if this is a really silly question. I googled a lot and nothing came up
I have this in my php.ini file:
extension_dir="C:\Program Files\PHP\ext"
enable_dl = on
extension=php_mysql.dll
when I call the phpinfo() function it says that there aren't any loaded modules.
I am using the latest version of apache, php and MySQL in a windows operating systems.
Also, I have used a WAMP server but I prefer having things separately and I want to learn how to do it
Thanks in advance
You need to enable the mysql extension itself in php.ini too. For example if you want to use mysqli, you need to add this to your php.ini file:
extension=php_mysqli.dll
also make sure that you have this dll file in your ext directory.

Using php_fileinfo.dll and finfo_open in Windows PHP 5.3.5

I'm having trouble calling finfo_open in a PHP script running on Windows Server 2003 with PHP 5.3.5 & IIS 6. The call always returns Fatal error: Call to undefined function finfo_open() in...
Through a little reading I know that fileinfo functionality is not included by default in the windows PHP installation, though nothing I try gets it working. The instructions in comment #3 here: http://www.php.net/manual/en/fileinfo.installation.php didn't help, and that's the most official looking explanation I can find. There's lots of information about needing the mime_magic dll on the web but it seems like this is no longer required as of 5.3. Furthermore, I have read on http://pecl.php.net/package/Fileinfo that "As of PHP 5.3.0 this extension is enabled by default". What's going on?
This issue is on a testing server. On my local machine I have xampp and PHP 5.3.1 and the call works fine, so I also tried copying the php_fileinfo.dll from local to php\ext on testing but this also didn't make any difference (I know that versions are different, but I read that the 5.3 is the important bit).
Any advice on this would be much appreciated!
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $filepath);
You're already close to get it done, only some little configuration is missing on your end.
Please see the fileinfo usage and installation instructions:
Windows users must include the bundled php_fileinfo.dll DLL file in php.ini to enable this extension.
That DLL file is bundeled with PHP 5.3.6 for example, you can find the files here: PHP For Windows - Binaries and sources Releases. It should be already located in the ext subdirectory of your PHP installation. If not download it again from the said website (choose your PHP version) and place it into the extension directory.
You need to add the following line your php.ini then to activate it:
extension=php_fileinfo.dll
That's the standard procedure to activate a PHP extension under windows. You can find more information about how to actiave a PHP extension here: Installation of extensions on Windows. If you have problems to locate the php.ini file, please refer to the PHP installation instructions - Installation on Windows systems.
This line
extension=php_fileinfo.dll
was commented in my php.ini so I uncommented it and then restarted my xampp server.
After doing what hakre suggested, the FileInfo extension was still not loaded at my end, but then eventually I solved it by figuring out that the php.ini file I was modifying was the wrong one (that was located at \MAMP\bin\php\php7.2.10) whereas the correct one was located at \MAMP\conf\php7.2.10.
After enabling it in the correct ini file, I had to restart the php server and off it worked.
NOTE: You might have to replace '\MAMP' from the start of the path with the path where your web-server solution stack software (e.g. MAMP, WAMP, XAMP or else) is installed. Since I was using MAMP that's why its present in my file path

Categories