Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: eselick (---.cpe.internexe.net)
Date: January 01, 2020 03:05AM

Here's my system info.
1 - Windows Microsoft Windows 10 Home
Version 10.0.18362 Build 18362, System Type x64-based PC
2 - Version WampServer Version 3.2.0 - 64bit
3 - Apache Version Apache/2.4.41 (Win64)
4 - PHP Version PHP/7.3.12 - Port defined for Apache: 80
5 - MySQL Version - not installed
5a - MariaDB n/a
6 - What color is the WampServer icon:Green
7 - In the file c:\Windows\System32\drivers\etc\hosts, what are the active lines?
#
127.0.0.1 localhost
::1 localhost
If the WampServer icon is green:
8 - Do you have access to localhost (Homepage WampServer) - Yes
8a - If so, is there an error message at the bottom of the page? - No
9 - Do you have access to phpMyAdmin? - Yes
11 - If you use an Antivirus and / or Firewall, please include the names of these: Trend Micro
12 - What is the full path to the installation of WampServer (eg D:\wamp\) - C:\wamp64

EXACT error message:
I’m trying to install DaDaBik – a php form builder using MS sqlserver as my database engine
When I key in [localhost] I get the following error:

( ! ) Error: Undefined class constant 'SQLSRV_ATTR_ENCODING' in C:\wamp64\www\magnal\include\config.php on line 1072

The actual lines in config.php that trigger the error are:
if ($dbms_type === 'sqlserver'){
// MS SQL Server unicode connection encoding
$sqlserver_conn_additional_attributes[PDOSQLSRV_ATTR_ENCODING] = PDOSQLSRV_ENCODING_UTF8;
}
The forum editor is messing up the PDOSQL strings which actually have double colons between PDO and SQLSRV in the original file.
Thanks
Elliot

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: Otomatic (Moderator)
Date: January 01, 2020 09:46AM

Hi,

> When I key in 'http://localhost/magnal/install.php' I get the following error:
No.
Your local sites must be in VirtualHost and the VirtualHost MUST exist BEFORE installing a local site.
See : The need for Virtual Host and Wampserver 3 - Create or add a VirtualHost

> ( ! ) Error: Undefined class constant 'SQLSRV_ATTR_ENCODING'
> in C:\wamp64\www\magnal\include\config.php on line 1072
This undefined constant defect has absolutely nothing to do with Wampserver.
This forum is not intended to debug PHP scripts or SQL queries from users.

Subsidiary question :
Why would you want to use Microsoft SQL Server when on the one hand dadabik supports MySQL, PostgreSQL, SQLite and Microsoft SQL Server and on the other hand MySQL is an integral part of Wampserver, but not SQL Server.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 01/01/2020 10:39AM by Otomatic.

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: eselick (---.cpe.internexe.net)
Date: January 02, 2020 04:33AM

I work for a company that has been using MS SQL serve for a while - so I don't have much choice there.

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: RiggsFolly (Moderator)
Date: January 02, 2020 10:47AM

Hi

Did you install the relevant SQL Server extension for the version of PHP that you are using? It does not come as part of WAMPServer out of the box.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: Otomatic (Moderator)
Date: January 02, 2020 11:07AM

Hi,

See [stackoverflow.com]

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: eselick (---.cpe.internexe.net)
Date: January 02, 2020 03:06PM

I'm a noob at this so please be patient.

I've installed the latest microsoft sqlserver driver in

C:\wamp64\bin\php\php7.3.12\ext
This folder seems to correspond to the latest microsoft dll's which have names like:

php_pdo_sqlsrv_73_ts_x64.dll

There are five of these files for both 64 bit and x86

I've also tried to edit

C:\wamp64\bin\apache\apache2.4.41\bin\php.ini

to add the line

extension=php_sqlsrv_72_ts.dll

I exited WINAMP and then reloaded it however the php.ini file is always recreated with 0 bytes. It seems like
it's always overwritten as part of the start up process.

I had backed it up and it was zeroed out even after I restored the original php.ini file.

So which php.ini file in which folder should I be adding the 'extension' line to?

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: RiggsFolly (Moderator)
Date: January 02, 2020 04:12PM

The best and safest way to edit the correct php.ini file is to use the menus system provided by the WAMPServer icon.

Left click - wampmanager -> PHP -> php.ini

Add the new extension line to that file where you find all the other Extension lines (they are in alphabetical order to make finding one easier.

Once you add the line, save the file and then restart Apache, also using the menu.

Left click wampmanager -> Apache -> Service Administration -> Restart Service

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: Otomatic (Moderator)
Date: January 02, 2020 04:30PM

Hi,

Left-click -> PHP -> php.ini opens the correct file in the text editor you have set by default.

The "real" file to edit is wamp64/bin/php/php7.3.12/phpForApache.ini, depending on the version of PHP you are using.

> C:\wamp64\bin\apache\apache2.4.41\bin\php.ini
This is not a file but a symbolic link on the phpForApache.ini file of the PHP version used, this can be seen by doing a dir *.ini command in the bin directory of Apache:
E:\wamp64\bin\apache\apache2.4.41\bin>dir *.ini
02/01/2020  15:17    <SYMLINK>      php.ini [E:/wamp64/bin/php/php7.4.1/phpForApache.ini]
                            1 file(s)                     0 bytes
By the way, all symbolic links can be seen by the command dir /al
E:\wamp64\bin\apache\apache2.4.41\bin>dir /al
 Repertory of E:\wamp64\bin\apache\apache2.4.41\bin

02/01/2020  15:17    <SYMLINK>      icudt65.dll [E:/wamp64/bin/php/php7.4.1/icudt65.dll]
02/01/2020  15:17    <SYMLINK>      icuin65.dll [E:/wamp64/bin/php/php7.4.1/icuin65.dll]
02/01/2020  15:17    <SYMLINK>      icuio65.dll [E:/wamp64/bin/php/php7.4.1/icuio65.dll]
02/01/2020  15:17    <SYMLINK>      icuuc65.dll [E:/wamp64/bin/php/php7.4.1/icuuc65.dll]
02/01/2020  15:17    <SYMLINK>      libpq.dll [E:/wamp64/bin/php/php7.4.1/libpq.dll]
02/01/2020  15:17    <SYMLINK>      libsasl.dll [E:/wamp64/bin/php/php7.4.1/libsasl.dll]
02/01/2020  15:17    <SYMLINK>      libsodium.dll [E:/wamp64/bin/php/php7.4.1/libsodium.dll]
02/01/2020  15:17    <SYMLINK>      libsqlite3.dll [E:/wamp64/bin/php/php7.4.1/libsqlite3.dll]
02/01/2020  15:17    <SYMLINK>      libssh2.dll [E:/wamp64/bin/php/php7.4.1/libssh2.dll]
02/01/2020  15:17    <SYMLINK>      php.ini [E:/wamp64/bin/php/php7.4.1/phpForApache.ini]
02/01/2020  15:17    <SYMLINK>      php7ts.dll [E:/wamp64/bin/php/php7.4.1/php7ts.dll]
              11 files(s)                0 bytes
It is not mandatory to restart Wampserver after each modification of the php.ini file, just do:
Right-Click -> Refresh

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: eselick (---.cpe.internexe.net)
Date: January 02, 2020 09:43PM

Where exactly should I be left clicking to open PHP.INI in my text editor; in Start Menu Programs, or windows explorer or elsewhere? Thanks for the help.

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: Otomatic (Moderator)
Date: January 02, 2020 10:44PM

Hi,

Left-click on Wampmanager tray icon

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: eselick (---.cpe.internexe.net)
Date: January 03, 2020 12:43AM

Making a bit of progress. I know I'm editing the correct php.ini now since I'm getting different error messages after the edit. It's unfortunate that I can't upload an image, in any case when I look at php extensions in wamp manager and go to the bottom where errors are showing it seems to have contradictory messages.

First there are a list of php_pdo files for MS sqlserver for which there is no "extension=" in the php .ini file.

Then there is list of "extension=" lines in php.ini for which there are no .dlls. However the following two entries are in both error lists and I"veadded the following 2 lines to php.ini:

extension=php_sqlsrv_73_ts_x64.dll
extension=php_sqlsrv_73_ts_x86.dll

and the same filename without extension appear in both error lists.

When I click on php version I'm getting a check mark beside 7.3.12 and the corresponding folder has all my dll files including the ones that are shown as missing.

Any ideas?

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: RiggsFolly (Moderator)
Date: January 03, 2020 01:05AM

Well you are either running a 32bit WAMPServer (and therefore 32bit PHP)
OR
you are rrunning a 64bit WMPServer and therefore a 64bit PHP.

So you dont want BOTH of the extensions active !!

If you are 64bit use
extension=php_sqlsrv_73_ts_x64.dll

If you are 32bit use
extension=php_sqlsrv_73_ts_x86.dll

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: eselick (---.cpe.internexe.net)
Date: January 03, 2020 04:57AM

It's working now. I see the php_pdo_sqlsrv_73_ts_x64 as being an active extension.
I needed to add the following line to php.ini

extension=php_pdo_sqlsrv_73_ts_x64.dl

which was required as well as

extension=php_sqlsrv_73_ts_x64.dll

I'm still getting errors during the connection to the database but I believe I know what's causing them.
Thanks for getting me through this smiling smiley

Options: ReplyQuote
Re: Error Undefined class constant 'SQLSRV_ATTR_ENCODING'
Posted by: Otomatic (Moderator)
Date: January 03, 2020 09:25AM

Hi,

For errors: Undefined class constant 'SQLSRV_ATTR_ENCODING', did you go and see at stackoverflow:

undefined-class-constant-sqlsrv-encoding-system

there is the answer to correct this error.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.