PHP Classes

jlaso php tools

Recommend this page to a friend!

      jlaso PHP tools  >  All threads  >  jlaso php tools  >  (Un) Subscribe thread alerts  
Subject:jlaso php tools
Summary:error message
Messages:4
Author:Don Filer
Date:2014-08-17 03:38:54
 

  1. jlaso php tools   Reply   Report abuse  
Picture of Don Filer Don Filer - 2014-08-17 03:38:54
The program example.php produces an error and I don't know how to resolve it.
Fatal error: Call to a member function fetch_all() on a non-object in /home/donfaeyz/public_html/example.php on line 134

The third line is where the offending code is:

echo '<label>Select Statement</label>';
$res = $con->Select('tab_teste');
$tab = $res->fetch_all(MYSQLI_ASSOC);
if (is_array($tab)){
$_cols = Array();
foreach ($tab as $key => $row) {
foreach ($row as $col => $val) {
if (count($_cols) != count($row)) $_cols[] = $col;
else break;
}
break;
}

Any assistance will be greatly appreciated.

Don Filer

  2. Re: jlaso php tools   Reply   Report abuse  
Picture of Joseluis Laso Joseluis Laso - 2014-08-18 07:13:52 - In reply to message 1 from Don Filer
Hi Don,

my php-tools.php package doesn't have any example.php, if I don't remember bad.

But I think that you have not well configured the access to DB, the error you have getting indicates that $con is not an object because no connection with DB have been initiated.

Please, revise the 9th line of php-tools.php, where require_once __DIR__.'/../config.php' and then, or put a file called config.php with declaration of constants DB_HOST, DB_USUARIO, DB_PASSWORD and DB_NAME or declare this constants in the place of this line, for instance:

@define ("__DIR__",dirname(__FILE__));
// require_once __DIR__.'/../config.php';

define("DB_HOST", "localhost");
define("DB_USUARIO", "root");
define("DB_PASSWORD", "passwd");
define("DB_NAME", "myDB");

class DbTools {

Let me know please if I understood well your issue ...

  3. Re: jlaso php tools   Reply   Report abuse  
Picture of Don Filer Don Filer - 2014-08-18 18:21:19 - In reply to message 2 from Joseluis Laso
Hi Patrick,

Thank you for responding to my question. I understand your solution, as well as the problem, not connecting with the database. I will try to put your suggestion to work. Thanks again.

Don

  4. Re: jlaso php tools   Reply   Report abuse  
Picture of Joseluis Laso Joseluis Laso - 2014-08-18 19:00:03 - In reply to message 3 from Don Filer
HI Don,

I just updated the package including config.php and I'm preparing a little example.

Thank you for report this issue. I seen that the package need to be updated and translated to english in order to allow people to use it.

Regards.