Undefined Constant MYSQLI_ASYNC - Non blocking queries in PHP - php

I understand that mysqlnd allows non blocking queries. However, I'm trying:
// goes without saying this code works correctly when second parameter is ommitted
$link->query($myQuery, MYSQLI_ASYNC);
The error I get is:"Notice: use of undefined constant MYSQLI_ASYNC assumed 'MYSQLI_ASYNC' "
and ensuing errors.
PHP Version: 5.3.5-1 ubuntu7.4
I don't know if I actually have mysqlnd installed/activated, and I can't find a good resource on how to tell if it is.
Help?

The most likely cause for this is that the mysqlnd extension is not installed. Please note, according to docs any PHP version less than PHP 5.4 will need to explicitly configure to use mysqlnd; starting with PHP 5.4 mysqlnd will be enabled by default.
There are a couple different ways to tell if you have an extension loaded.
phpinfo() should output a section labeled mysqlnd
extension_loaded('extension_name') should return true/false whether or not you have the extension loaded

Related

PHP Warning: PHP Startup: Unable to load dynamic library '- The specified procedure could not be found. in Unknown on line 0

I would like to change php version to 7.1 and i have an error:
PHP Warning: PHP Startup: Unable to load dynamic library
'C:\Program Files\PHP\v7.1\ext\php_sqlsrv_7_nts_x86.dll' - The specified procedure could not be found.
in Unknown on line 0
First think. This is not duplicate question because i checked many similar questions.
I'm using IIS, PHP 7.1, and SQL server (thats why i need sqlsrv drivers).
I checked php.ini file aready and i change extension-dir path to full path but nothing happens. (Logically if path is a problem why it works with other extensions? ).
It works with PHP 7.0.7 (all enabled extensions is exactly same)
Update: still won't work but i tried to paste path from error message to file explorer and file already there.
Turns out that PHP 7.0 and PHP 7.1 are not compatible and the mssql PDO drivers are for 7.0.
Github issue here
Also ensure you including the right 64/86 and ts/nts version.
As from Toby Allen's accepted answer above 7.0 and 7.1 are incompatible,
However Microsoft has released Preview versions of the drivers for 7.1.
This worked for me, hope it helps anyone searching.
Drivers can be found here under downloads
I had this issue yesterday. The key to the error is the last bit.
The specified procedure could not be found.
In my case I went through a painful amount of debugging. The first thing that I noticed was that when I ran a hello world php file, I didn't get this error. That indicated to me it wasn't actually a problem loading the file, it was a problem calling a function in the file.
I went in and repeatedly put die() statements in and moved it until it hit the error. It took awhile but I eventually discovered I was calling sqlsrv_connect with options that were (apparently) now invalid.
So I can't say the exact cause of your issue without seeing the code that actually causes the error, but I hope this at least points you in the right direction.

How to check if my php version is going to understand DIRECTORY_SEPARATOR if its version dependent

I am not sure about which platform my code goes to host, so im using directory separator in my code.
I followed this link - how-to-get-a-platform-independent-directory-separator-in-php
but the accepted answer is not what i am looking (string replacement). Although another solution with "DIRECTORY_SEPARATOR" is something what I was looking for but my concern is when i checked the docs at -> dir.constants
They said - The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
So from where I can check whether this extension is available or not, I checked from phpinfo() method but unable to locate under it, how can I locate this whether installed or not ? . If its available in all so can i proceed with this dummy code or not -
$headurl = $_SERVER['SERVER_NAME'].'/'.'backgroundimage.jpg';
These constants are extension dependent but its part of PHP now. See dir.installation.
There is no installation needed to use these functions; they are part of the PHP core.
Even in requirements Its stated
No external libraries are needed to build this extension.
So you dont have to worry about it. Every platform will support this constant
DIRECTORY_SEPARATOR is predefined constant and available in all PHP versions right from the start to ensure cross OS file system compatibility. you can use it.
note: this is also indicated in your reference http://php.net/manual/en/dir.constants.php (by the missing "Available since PHP x.x.x.". e.g. PATH_SEPARATOR is "Available since PHP 4.3.0.").

Patch PHP 5.3.10 to support sybase_next_result()

The database management system Sybase ASE supports multiple result sets, however the implementation of Sybase in PHP doesn't. There is a bug reported on this issue and there is also a patch supplied in that report (https://bugs.php.net/bug.php?id=48675). The patch is for version 5.2.9 and I've tried to add it to version 5.3.10. The source builds without warnings or errors, and testing the new function 'sybase_next_result()' does not yield a fatal error "Call to undefined function". This would suggest that the function is implemented, but not working as expected.
Configuration is:
configure --disable-isapi --enable-debug-pack --without-mssql --without-pdo-mssql --without-pi3web --with-mcrypt=static --disable-static-analyze --enable-cli --with-sybase-ct=%SYBASE%\%SYBASE_OCS%
There is a notice on 'sybase_query()' when there are multiple result sets saying "Sybase: Unexpected results, cancelling current in...". The first result set is retrieved. And this notice is returned even without the patch.
The number of stored procedures in the database that return multiple result sets is vast, and a 'sybase_next_result()' would be the best solution. In short, I looking for an equivalent to 'mssql_next_result()' (http://se2.php.net/manual/en/function.mssql-execute.php) for Sybase in PHP 5.3.10.
Worth noting is that the other parts of the Sybase implementation is in place and seems work as expected.
My testing environment is a WAMP server (Windows 7, Apache 2.21, MySQL 5.5.20, PHP 5.3.10) and Sybase ASE is version 15.7.0.
Is there anyone out there that has "solved" this?
With regards
//Jonas
Update:
A colleague gave me the instructions to use 'OutputDebugString()' (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx) and catch that with DebugView (http://technet.microsoft.com/en-us/sysinternals/bb896647).
From this I can say that 'sybase_next_result()' is called but the block
if (sybase_ptr->active_result_index) {
...
}
is not run. This is probably correct (as I see it).
The row
retcode = ct_results(sybase_ptr->cmd, &restype);
is always setting 'retcode' to 'CS_FAIL'. This is perhaps because the earlier
ZEND_FETCH_RESOURCE2(sybase_ptr, sybase_link *, sybase_link_index, id, "Sybase-Link", le_link, le_plink);
sets 'sybase_ptr' in sutch fashion that 'retcode' becomes 'CS_FAIL'.

Call to undefined function sqlite_escape_string()

i am using sqlite_escape_string($str) to prepare sql statements for future use.
however, when i migrated my code to a new server, it says:
Call to undefined function sqlite_escape_string()
seems the Sqlite and everything is working in the new server, but i have error even for a sqlite_open().
Anyways, i just need to escape my $str to a sqlite safe sql statments, i dun even need to write to sqlite from PHP, so an
That sounds like the SQLite plugin is not enabled for PHP. Write <?=phpinfo()?> in a .php file, load it up on your server and see if SQLite is mentioned in the loaded plugins.
You need to uncomment the extension=php_sqlite.dll line by removing the semi colon right now your pdo_sqlite is enabled and sqlite_escape_string is a function of sqlite extension and sqlite_pdo will not work untill php_sqlite is enabled
I found the ans myself.
It is due to my server is a Centos 5.4, and sqlite support for php is not there.
The same case should exist in REL5 also.
see the 1st and 2nd latest comment in the link below:
http://www.php.net/manual/en/sqlite.installation.php
I solved it by recompiling my php and added the sqlite.ini file
For those who recently upgraded to 5.4+, note that the php docs say, this method is not available 5.4+
(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)
So you would either need to manually compile it in, or look at PECL.

OpenSSL enabled but not working

I am running Apache 2.2.13 and PHP 5.2.12. Just installed PHP 5.2.12 manually (to have access to all extensions) and enabled OpenSSL. phpinfo() indicates OpenSSL is enabled and running OpenSSL 0.9.8k 25 Mar 2009.
I'm getting this error: PHP Fatal error: Call to undefined function ftp_ssl_connect().
I've seen where the PHP manual suggests 'ftp_ssl_connect() is only available if both the ftp module and the OpenSSL support is built statically into php' and further states that 'you must compile your own PHP binaries' to make it work with Windows.
I have the suspicion that phpinfo() only indicates OpenSSL as being 'enabled' because I have uncommented the line 'extension=php_openssl.dll' and have the correct dlls in the correct folders and the correct path in the environment variables. And perhaps a static build into PHP must be accomplished regardless of what phpinfo() indicates.
I believe the objective of distribution (as described above) is for dynamic extensions, but recompiling (for OpenSSL) is to encode a static extension.
ftp extension is working fine (built into PHP 5.2). I test this with the following code:
$conn_id = ftp_connect($url);
$login_result = ftp_login($conn_id, $username, $password);
ftp_close($conn_id);
Note that to check ssl, I only change ftp_connect to ftp_ssl_connect. When reaching this line, I get the PHP error above in my Apache error log file.
As the documentation states (quoting what you already quoted) :
Note: Why this function may not exist
ftp_ssl_connect() is only
available if both the ftp module and
the OpenSSL support is built
statically into php, this means that
on Windows this function will be
undefined in the official PHP builds.
To make this function available
on Windows you must compile your own
PHP binaries.
You say you installed PHP "manually" ; but this probably still means you used an "official" build from php.net -- which means you have not compiled your own PHP binaries... So, that function is not available.
There is no magic : it seems you'll have to re-compile PHP, using the right configuration options at compile-time, if you want to be able to use that function...
Here's some documentation about that : Build your own PHP on Windows -- but... good luck... i've never heard it was "simple" to compile PHP on windows, actually (it's not that hard on Linux, but Linux is maybe a bit more well suited when it comes to compilation)
A couple of other solutions :
switching to Linux for your developments (even if it's only using a Virtual Machine) -- but you might still have to recompile PHP to get that (might not be enabled by default)
just not using that function ; after all, do you know if your hosting service will provide you with it ? (If you can't use it on your production server, no need to use on your development/testing machine)

Categories