CodeIgniter Forums
CI 1.7: mysqli error when using empty port - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI 1.7: mysqli error when using empty port (/showthread.php?tid=12577)



CI 1.7: mysqli error when using empty port - El Forum - 10-24-2008

[eluser]sinzy[/eluser]
Hi, there, just upgraded to CI 1.7, however my app reports "Unable to connect to your database server using the provided settings."

After some investigation, I think it is because of the new "port" support for mysql/mysqli. (My app uses mysqli).

By default, in DB_driver.php, $port = ''. And in mysqli_driver.php, the db_connect() function just use this empty port, so there is an error. If I remove the $this->port in this function, my app works again.

But in mysql_driver.php there is a check for port, so no problem.

It is a bug I think. Smile


CI 1.7: mysqli error when using empty port - El Forum - 10-24-2008

[eluser]thespy[/eluser]
same problem here after updating from 1.6.3 to 1.7 :

ERROR - 2008-10-24 16:20:37 --> Severity: Warning --> mysqli_connect() expects parameter 5 to be long, string given /home/site.com/codeigniter_system/database/drivers/mysqli/mysqli_driver.php 63
ERROR - 2008-10-24 16:20:37 --> Unable to connect to the database

And problem fixed with remove the "port" parameter in mysqli_driver.php


CI 1.7: mysqli error when using empty port - El Forum - 10-24-2008

[eluser]narkaT[/eluser]
a fix that not requires hacking the core files:

in APP/config/database.php add the following line
Code:
$db['default']['port'] = "3306";

if you renamed the database group remember to change 'default' to what ever you named it Wink


CI 1.7: mysqli error when using empty port - El Forum - 10-24-2008

[eluser]Derek Jones[/eluser]
Thanks, fixed in the SVN. How rude of PHP to try to use an empty string as a long integer.


CI 1.7: mysqli error when using empty port - El Forum - 11-26-2008

[eluser]Ricardo Rodrigues[/eluser]
Worked! Thanks!