I have problem when I wanted to put website to hosting. I am using nette and when I want to connect I get error
PDO::__construct(): Premature end of data (mysqlnd_wireprotocol.c:553)
I am using nette framework with this db config:
dsn: 'mysql:host=dbhost;dbname=dbtable'
user: dbuser
password: dbpass
When I have tried classic connection, it is working correctly. I am not sure what to do and how to solve this.
if($myslConnection = mysql_connect("dbhost", "dbuser", "dbpass")){
echo("connected");
mysql_select_db("dbtable",$myslConnection);
$result = mysql_query("SELECT * FROM news", $myslConnection);
while($resultItem = MySQL_Fetch_Row($result)){
echo $resultItem[1]."<br>";
}
}
else{
exit("not connected");
}
edit: error what I have got
Warning: PDO::__construct() [pdo.--construct]: Premature end of data (mysqlnd_wireprotocol.c:553) in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php on line 5
Warning: PDO::__construct() [pdo.--construct]: OK packet 1 bytes shorter than expected in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php on line 5
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file' in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php:5 Stack trace: #0 /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php(5): PDO->__construct('mysql:host=tran...', 'user', 'pass') #1 {main} thrown in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php on line 5
Related
Software:
PHP 7.3
MySQL Workbench 8.0
This is my PHP code:
try {
$link = mysqli_connect($DB_SERVER,$DB_USERNAME, $DB_PASSWORD,$DB_NAME,3306);
} catch (Exception $e){
throw new Exception("Can't execute command. ERROR: ".$e);
}
This is the error:
Warning: mysqli_connect(): PHP was built without openssl extension, can't send password encrypted in login.php on line 11
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'XXXXX_admin'#'localhost' (using password: YES) in C:\inetpub\wwwroot\ on line 11
PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\inetpub\wwwroot\ on line 24
PHP Fatal error: Uncaught Exception: ERROR: Failed to connect to in C:\inetpub\wwwroot:24 Stack trace: #0 {main} thrown in C:\inetpub\wwwroot\ on line 24
Now the magic, when I login in to mysql workbench with the same user and password everything works fine. I have access to tables and other things. When I login in with my PHP application everything works also.
So my problem is everytime my server reboots I have to login in with MySQL Workbench, to get it working again. What am I missing?
You need to do verify few of the steps:
All necessary extensions are enabled like mysqli, openssl etc
Port is available
MySQLi is connecting at 3306 Port
Rest could be your username and password issue
Let us know once you will be verifying all above steps.
What you need to do is enable the openssl extension for php.
Open your php.ini file and search for the line:
;extension=php_openssl.dll
You need to uncomment it by removing the semicolon in front of it, leaving you with this:
extension=php_openssl.dll
I am trying to learn about PDOs so I can migrate away from using mysqli functions but I can't seem to get the DSN right when connecting to the database. I don't know what charset to use. Is it something that I determine in phpmyadmin or is it something that is already set and I have to find? Not sure.
I have a MySQL database set up on a XAMPP program that I am trying to connect to. Below is my code from my db.php file and the full error message.
// CREATE PDO OBJECT WITH CONSTRUCTOR
$db = new PDO('mysql:host=localhost;dbname=phpdemo;charset=utf8', 'root', '');
// SET ATTRIBUTE RELATED TO ERROR HANDLING FOR SECURITY
$db -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$fb -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2019] Unknown character set in C:\xampp\htdocs\PHP\PDO Lab\includes\db.php:3 Stack trace: #0 C:\xampp\htdocs\PHP\PDO Lab\includes\db.php(3): PDO->__construct('mysql:host=loca...', 'root', '') #1 C:\xampp\htdocs\PHP\PDO Lab\includes\header.php(6): include_once('C:\xampp\htdocs...') #2 C:\xampp\htdocs\PHP\PDO Lab\new_user.php(2): include_once('C:\xampp\htdocs...') #3 {main} thrown in C:\xampp\htdocs\PHP\PDO Lab\includes\db.php on line 3
Edit: I have tried using utf8mb4 which results in the same error.
Edit2: I just realized that I don't get any errors when I open my db.php file. I do get errors when I open my new_user.php file who's only code is "include('db.php');"
I'm trying to connect to a Foxpro database using the OLE DB Driver
I downloaded the driver from http://www.microsoft.com/en-us/download/details.aspx?id=14839 and installed it then create a php script
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=vfpoledb.1;Data Source=C:\Opera3\Comp_I.DBC;Collating Sequence=machine");
This gives me the following error
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Connection<br/><b>Description:</b> Provider cannot be found. It may not be properly installed.' in C:\inetpub\wwwroot\test1.php:4 Stack trace: #0 C:\inetpub\wwwroot\test1.php(4): com->Open('Provider=vfpole...') #1 {main} thrown in C:\inetpub\wwwroot\test1.php on line 4
Any help in getting this working would be much appreciated.
As requested
uninstalled and reinstalled from command line as administrator for all users and now it works –
i have big problem while connection to a remote informix database server.
here's the code
$db = new PDO("informix:host=192.168.*.*; service=1565;
database=daten; server=name; protocol=onsoctcp;
EnableScrollableCursors=1", "informix", "info00");
print "Connection Established!\n\n";
echo "Table contents: $rows.\n";
I receive the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -917 [Informix][Informix ODBC Driver][Informix]Must close current database before using a new database.' in /var/www/informix.php:9 Stack trace: #0 /var/www/informix.php(9): PDO->__construct('informix:host=1...', 'informix', 'info00') #1 {main} thrown in /var/www/informix.php on line 9
How can I fix this?
I think you should also set the DB_LOCALE environment variable.
When the client application requests a connection, it sends information, including the DB_LOCALE to the database server.
I have installed PDO_INFORMIX and CSDK already on CentOS5.6 32bits
and index.php have
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$db = new PDO("informix:host=172.30.179.81; service=5000;database=cms; EnableScrollableCursors=1", "myuser", "mypassword");
print("OK");
?>
but i still got this error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -11060 [Informix][Informix ODBC Driver]General error.' in /usr/local/apache/htdocs/index3.php:5 Stack trace: #0 /usr/local/apache/htdocs/index3.php(5): PDO->__construct('informix:host=1...', 'myuser', 'mypassword') #1 {main} thrown in /usr/local/apache/htdocs/index3.php on line 5
Have anyone know what it is ?
Thanks
Ouch! The standard technique for finding out more about errors is:
$ finderr -11060
-11060 General error.
An error occurred that has no specific SQL_STATE. In this case,
additional text is provided that identifies the source of the problem.
This IBM Informix CLI error code is the same as SQLSTATE value S1000.
$
That is not very helpful - to be polite about it.
There are spaces in the connect string; does removing them help at all?
Can you telnet to the host 172.30.179.81?
Can you telnet to the port (service) 5000 on the host?
Can you connect from this machine using any other Informix tool?
Can you connect from other machines using the same connect string?
In case of desparation, can you track down whether all the shared libraries are loading correctly?