SSH in xampp install php - php

I need to use a connection SSH and PHP, I have version PHP 5.6.8 ,
intall OpenSSL-Win32;
In php.ini :
extension=libssh2.dll ;librerias ssl2
extension=php_ssh2.dll
The libraries are in the folder php---->ext.
With the next program my result is:
Fatal error: Call to undefined function ssh2_connect() in
C:\xampp\htdocs\conexion\conexion_ssh.php on line 2
<?php
$connection = ssh2_connect('X.X.X.X', XX);
if (ssh2_auth_password($connection, 'root', 'XXXXXXXX')) {
echo "Authentication Successful!\n";
} else {
die('Authentication Failed...');
}
?>
Do you know the problem? I think is the configuration the system variable PATH but I don't Know the process.
Thanks for you help me!

Related

Fatal error: Uncaught Error: Call to undefined function db2_connect()

I have some problem. I have been looking it for almost a week. I have done include ibm_db2.dll, change php version but not working. When I run the db2 query, it shows Fatal error: Uncaught Error: Call to undefined function db2_connect() in C:\laragon\www\hpc_dev\db2_conn.php:15 Stack trace: #0 C:\laragon\www\hpc_dev\index.php(3): include() #1 {main} thrown in C:\laragon\www\hpc_dev\db2_conn.php on line 15
Currently I am using php version 7.4.12 64bit (ts) using laragon in Windows 10. I also have tested using Xampp and the same problem occur. Below are my codes to connect to ibm db2:
db2_conn.php:
<?php
ini_set("display_errors", 1);
$database = 'DB2';
$user = 'xxx';
$password = 'xxx';
$hostname = 'xx.xx.xx';
$port = 60000;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
$conn = db2_connect($conn_string, '', '');
if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.";
}
?>
My code to show data from db2:
<?php
include("db2_conn.php");
$sql = "SELECT * FROM EMPLOYER WHERE EMPR_LOGIN_NAME = 'xxxxx'";
if ($conn)
{
$stmt = db2_exec($conn, $sql);
$row = db2_fetch_assoc($stmt);
echo $row['SECTOR_DESC'];
db2_close($conn);
}
?>
I don't know either the problem comes from db2 extension or others. Please help me.
For information, I have download the ibm db2 extension here: https://github.com/ibmdb/php_ibm_db2
Thanks
Your question omits details of the command-lines and actions you performed.
Most likely you missed a step in the configuration.
Remember to open the laragon terminal and verify that the Db2 driver is loaded:
php -m | grep ibm
should return ibm_db2 if you have correctly configured the correct version of the extension.
If you do not see that the ibm_db2 extension is loaded then any db2_connect will fail until you resolve the missing module.
For information the current laragon_full (November 2020) delivers PHP 7.2 TS, and that works correctly with the php_ibm_db2.dll TS for v7.2.x "out of the box" (which you must first download and configure).
Additionally, if I upgrade the PHP version for laragon to PHP 7.4.12 TS, and subsequently download and configure the matching php_ibm_db2.dll TS for php v7.4.x, then it all "just works" without any issues on Win 10 x64 2020 to connect to Db2-LUW and run queries etc.
It helps to verify that your Db2 client is correctly configured. You can do that independently of PHP. If you are using the clidriver Db2-client (the smallest footprint driver) you can configure the db2dsdriver.cfg XML file and then run db2cli validate -connect -dsn -user ... -passwd ... to verify that the connection works. If you are using either the Db2-runtime-client or the Db2 full client, or a local Db2-server, you can run (in the laragon terminal):
(after configuring your Db2 node directory and Db2 db directory via appropriate configuration commands )::
set DB2CLP=**$$**
db2 connect to $yourdsn user ... using ...

Class 'PDO' not found Error in Upload Laravel project on server [duplicate]

I have this PHP function which has been working very well until i reinstalled my dev system:
function connectDB($database, $username, $password) {
$DSN = "mysql:host=localhost;dbname=$database";
try {
$DBH = new PDO($DSN, $username, $password); <--- LINE 10
return $DBH;
}
catch(PDOException $e) {
die("Could not connect to the database.\n");
}
}
And i'm getting the error:
PHP Fatal error: Class 'PDO' not found in /var/www/im/tools.php on line 10
I checked phpinfo() and PDO is enabled:
PDO drivers : mysql
PDO Driver for MySQL version: 5.1.54
The interesting thing is that the interaction with th MYSQL database is ok, but i'm still getting the error when debugging.
I'm puzzled about this error! My system is Ubuntu 11.04 + NGINX + PHP 5.3
Any tip to get rid of it? Thanks!
Are you using namespaced code? Maybe you need to use \PDO class then?
This can also happen if there is a php.ini file in the web app's current working directory. If one has been placed there to change certain settings, it will override the global one.
To avoid this problem, don't use a php.ini change settings; instead, do this in the vhost declaration or a .htaccess file with 'php_flag'.
See also PHP Fatal error: Class 'PDO' not found
try
yum install php-pdo
service httpd restart

Call to undefined function geoip

I installed PHP 5.4 and GeoIP but I can't get the GeoIP to work.
the error is:
Fatal error: Call to undefined function geoip_country_code_by_name() in /var/www/html/geoip/test.php on line 7
This is the script:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
//$gi = geoip_open( "GeoIP.dat",GEOIP_STANDARD);
$country = geoip_country_code_by_name('www.example.com');
if ($country) {
echo 'This host is located in: ' . $country;
}
?>
I installed PEAR/PECL still nothing.
is there a log error for geoip or something that can help with is issue?
also I installed GeoIP with PHP 5.3 and it works fine. the problem is with PHP 5.4
Thanks.
There seems to be a mis-configuration or you are giving the function name wrong. To check that it's successfully installed/active;
if (function_exists("Function_Name_Here")) {
echo "Function Does Exist";
} else {
echo "Function Does Not Exist";
}
If this function "does not exist" then re-trace through your installation steps of consult the official manual of this extension for exact installation instructions.

Fatal error: Call to undefined function mysql_connect() [duplicate]

This question already has answers here:
Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2
(2 answers)
Closed 3 months ago.
I am getting this error Fatal error: Call to undefined function mysql_connect() in /var/www/html/test1.php on line 8
for the following code:
<?php
$host = "localhost";
$user = "user12";
$pass = "34klq*";
ini_set ('display_errors', 1);
$r = mysql_connect($host, $user, $pass);
if (!$r) {
echo "Could not connect to server\n";
trigger_error(mysql_error(), E_USER_ERROR);
} else {
echo "Connection established\n";
}
echo mysql_get_server_info() . "\n";
mysql_close();
?>
I have PHP, MYSQL, php-Mysql installed in my system:
[root#localhost ~]# rpm -qa | grep mysql
php-mysql-5.3.3-3.el6_2.8.i686
mysql-devel-5.1.61-4.el6.i686
mysql-server-5.1.61-4.el6.i686
mysql-bench-5.1.61-4.el6.i686
mysql-libs-5.1.61-4.el6.i686
mysql-5.1.61-4.el6.i686
[root#localhost ~]# rpm -qa | grep php
php-common-5.3.3-3.el6_2.8.i686
php-5.3.3-3.el6_2.8.i686
php-mysql-5.3.3-3.el6_2.8.i686
php-cli-5.3.3-3.el6_2.8.i686
php-pdo-5.3.3-3.el6_2.8.i686
output of phpinfo() :
http://jsfiddle.net/nit8899/GZ4f7/
Also I have edited the /etc/php.ini file:
extension=mysql.so
But even then I am getting this error.
You should open your php.ini file located in php folder, and uncomment this line of code:
;extension=php_mysql.dll
So it looks like this:
extension=php_mysql.dll
Your php folder location depends on your lampp/wampp installation, if using xampp its located in: xampp/php/php.ini
if you are working on linux [debian]
apt-get install php5-mysql
because your PHP is not able to talk with mysql
I cheated and looked on my phone
The build of your PHP spectifically says '--without-mysql'
Therefore, mysql functions will not be available.
You should rebuild.
Your PHP is configured with --without-mysql.
The documentation describes how to configure with mysql extension enabled. You may have your reasons, but PDO would be a better choice here is the documentation for configuring with PDO mysql.

PHP Fatal error: Class 'PDO' not found

I have this PHP function which has been working very well until i reinstalled my dev system:
function connectDB($database, $username, $password) {
$DSN = "mysql:host=localhost;dbname=$database";
try {
$DBH = new PDO($DSN, $username, $password); <--- LINE 10
return $DBH;
}
catch(PDOException $e) {
die("Could not connect to the database.\n");
}
}
And i'm getting the error:
PHP Fatal error: Class 'PDO' not found in /var/www/im/tools.php on line 10
I checked phpinfo() and PDO is enabled:
PDO drivers : mysql
PDO Driver for MySQL version: 5.1.54
The interesting thing is that the interaction with th MYSQL database is ok, but i'm still getting the error when debugging.
I'm puzzled about this error! My system is Ubuntu 11.04 + NGINX + PHP 5.3
Any tip to get rid of it? Thanks!
Are you using namespaced code? Maybe you need to use \PDO class then?
This can also happen if there is a php.ini file in the web app's current working directory. If one has been placed there to change certain settings, it will override the global one.
To avoid this problem, don't use a php.ini change settings; instead, do this in the vhost declaration or a .htaccess file with 'php_flag'.
See also PHP Fatal error: Class 'PDO' not found
try
yum install php-pdo
service httpd restart

Categories