PHP Classes

Cant't get it to work

Recommend this page to a friend!

      PHP MySQL to MySQLi  >  All threads  >  Cant't get it to work  >  (Un) Subscribe thread alerts  
Subject:Cant't get it to work
Summary:Error
Messages:4
Author:Finn Sommer
Date:2017-09-28 20:19:50
 

  1. Cant't get it to work   Reply   Report abuse  
Picture of Finn Sommer Finn Sommer - 2017-09-28 20:19:50
What am I doing wrong?

I have made a copy of working code from server with php5, and moved it to server with php7.

I get:

[Thu Sep 28 22:09:17.456336 2017] [:error] [pid 32433] [client IP:38958] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /var/www/html/FUmedlem/mydql2i/mysql2i.class.php on line 426, referer: http://IP/FUmedlem/index_auth.php
[Thu Sep 28 22:09:17.456380 2017] [:error] [pid 32433] [client IP:38958] PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /var/www/html/FUmedlem/mydql2i/mysql2i.class.php on line 395, referer: http://IP/FUmedlem/index_auth.php
[Thu Sep 28 22:09:17.456390 2017] [:error] [pid 32433] [client IP:38958] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /var/www/html/FUmedlem/mydql2i/mysql2i.class.php on line 155, referer: http://77.88.77.86/FUmedlem/index_auth.php

Finn Sommer

  2. Re: Cant't get it to work   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-09-28 20:44:55 - In reply to message 1 from Finn Sommer
Looks like you are not connecting to the database.

1) Make sure your credentials are correct for the mysql database on the new server (if using localhost) or that you are properly connecting to the mysql server remotely.

2) If the problem persists, after your script connects (probably somewhere in script init, config or connect file) check the value of mysql2i::$currObj to see if it is a mysqli object, you can use something like...

echo '<pre>';
var_dump(mysql2i::$currObj);
echo '</pre>';
die;

If it is null, you need to track down the connection issue. If it is a mysqli object, then the package is not properly handling the connection and I will have to run some tests on my code.

Dave

  3. Re: Cant't get it to work   Reply   Report abuse  
Picture of Finn Sommer Finn Sommer - 2017-10-02 12:57:10 - In reply to message 2 from Dave Smith
Thank you, so much!!
You just gave me the extra time I need.


  4. Re: Cant't get it to work   Reply   Report abuse  
Picture of Syai Razif Syai Razif - 2019-01-10 00:48:05 - In reply to message 2 from Dave Smith
hi i got this error when i put this code, maybe you can help me ?

object(mysqli)#3 (19) {
["affected_rows"]=>
int(-1)
["client_info"]=>
string(79) "mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $"
["client_version"]=>
int(50012)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["error_list"]=>
array(0) {
}
["field_count"]=>
int(0)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(23) "5.7.24-0ubuntu0.16.04.1"
["server_version"]=>
int(50724)
["stat"]=>
string(140) "Uptime: 159800 Threads: 9 Questions: 80215 Slow queries: 0 Opens: 6008 Flush tables: 1 Open tables: 416 Queries per second avg: 0.501"
["sqlstate"]=>
string(5) "00000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(292640)
["warning_count"]=>
int(0)
}