allinarush Posted February 24, 2017 Share Posted February 24, 2017 I have a site that is working on a hosted server. I setup PHP, MYSQL, and IIS on my local server. PHPMYADMIN works so I know that php is working. Im not that great at coding, and I keep getting errors at every turn. The hosted version of PHP that works is 5.6.-29, and the only version I could obtain was 5.6.30. {"errorMsg":"ErrNo: 8192, \r\n ErrStr: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead, \r\n ErrFile: C:\\inetpub\\wwwroot\\system\\core\\SpcDb.php, \r\n ErrLine: 108 (Cannot open file errors.log)","success":false} So I changed it to mysqli, then I got an error about mysql_select, so I changed it to mysqli_select and now im getting {"errorMsg":"ErrNo: 2, \r\n ErrStr: mysqli_select_db() expects exactly 2 parameters, 1 given, \r\n ErrFile: C:\\inetpub\\wwwroot\\system\\core\\SpcDb.php, \r\n ErrLine: 109 (Cannot open file errors.log)","success":false} What is confusing is that this test DB script works with mysql_connect just fine. Here is my original connection code... * Gets default mysql connection * * @param void * * @return resource */ public static function getDbConn($dbParams = null) { if ($dbParams !== null) { $host = $cfg['host']; $username = $cfg['username']; $password = $cfg['password']; $dbName = $cfg['dbName']; } else { if (self::$_conn) { return self::$_conn; } $host = SPC_DB_HOST; $username = SPC_DB_USERNAME; $password = SPC_DB_PASSWORD; $dbName = SPC_DB_DBNAME; } self::$_conn = mysqli_connect($host, $username, $password); mysqli_select_db($dbName); return self::$_conn; } Quote Link to comment https://forums.phpfreaks.com/topic/303287-migrated-working-app-to-locally-hosted-and-have-mysql_connect-errors/ Share on other sites More sharing options...
benanamen Posted February 24, 2017 Share Posted February 24, 2017 (edited) You cannot just through an i on the end of the deprecated functions. Take some time and read the manual. You should be using PDO anyways. https://phpdelusions.net/pdo Edited February 24, 2017 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/303287-migrated-working-app-to-locally-hosted-and-have-mysql_connect-errors/#findComment-1543329 Share on other sites More sharing options...
allinarush Posted February 24, 2017 Author Share Posted February 24, 2017 (edited) You cannot just through an i on the end of the deprecated functions. Take some time and read the manual. You should be using PDO anyways. https://phpdelusions.net/pdo Im not that good at coding. Im I.T. and was hoping someone can help me resolve this. Why is it that mysql_connect works on my test script but not this original script? Edited February 24, 2017 by allinarush Quote Link to comment https://forums.phpfreaks.com/topic/303287-migrated-working-app-to-locally-hosted-and-have-mysql_connect-errors/#findComment-1543330 Share on other sites More sharing options...
Barand Posted February 24, 2017 Share Posted February 24, 2017 \r\n ErrStr: mysqli_select_db() expects exactly 2 parameters, 1 given, There is a clue in that error message - wrong parameters. So look up the function mysqli_select_db in the PHP manual and see what the parameters should be Quote Link to comment https://forums.phpfreaks.com/topic/303287-migrated-working-app-to-locally-hosted-and-have-mysql_connect-errors/#findComment-1543331 Share on other sites More sharing options...
benanamen Posted February 24, 2017 Share Posted February 24, 2017 It doesn't matter. The code has been completely removed from Php. Don't use it. At the least, you should be using Mysqli Quote Link to comment https://forums.phpfreaks.com/topic/303287-migrated-working-app-to-locally-hosted-and-have-mysql_connect-errors/#findComment-1543332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.