Posts by black32

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

Following you and already some other guys ;)

My profile : Black32

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

Can someone help me ?

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

I have worked with codeigniter and I like the dbforge class. But now I am busy with creating a CMS and I would like to have a class with the same functionality as dbforge.

My question is : Does someone know were I can find such a class in php. Or : Does someone know a way how to get the dbforge class to work outside codeigniter without download all codeigniter files. ( only the dbforge class file ).

Best regards, Wouter van Marrum.

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

Thank you very much abhimanyusharma003 that just works fine for me :D This helps me a lot with my custom CMS :)

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says
one quick question I want to get my vars from a config file. First I had a class which had this :
var $host;
var $username;
var $password;
var $db;

But now I need to insert the values in the class itself instead of getting them from the config file.

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

Thanks abhimanyusharma003 !

Your code worked exactly how it should. Now I am recoding everything to mysqli haha. everyone else thanks for the help !


What about this one. Just created
class test
{
    protected $host = 'localhost';
    protected $username = 'root';
    protected $password = '';
    protected $db = 'database';
    protected $link = null;

    public function __construct()
    {
        $this->link = mysqli_connect($this->host, $this->username, $this->password, $this->db);
    }

    public function output()
    {
        $result = mysqli_query($this->link, "SELECT * FROM table LIMIT 10");
        return mysqli_num_rows($result); // THIS IS OUTPUT
    }
}

$test = new test();
echo $test->output();

Output will be 10
18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

I will try it out maybe it will work. I will let you know in a few hours thanks in advance

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

The error is pretty clear. You forgot to select your database (add the following code).
mysqli_select_db($this->db, $con);
Still doesn’t work.. now i get this error :
Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\projecten\shadowCMS_beta\shadow\classes\shadow.php on line 105

Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\projecten\shadowCMS_beta\shadow\classes\shadow.php on line 107
ShadowCMS could not select a database:
18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

Hello everyone.

I am busy creating a custom CMS that also uses a custom template engine. But i am coding with MySQL but I know i have to change to MySQLI.

Now the problem is that I can’t get it to work the way it is supposed to.

I created a function connect and it looks like this :

/* @function connect : This function will be used to establich a connection with the database. */ public function connect() { // Set up connection details for the site $con = mysql_connect($this->host, $this->username, $this->password); if (!$con) { die("ShadowCMS could not connect to the database: " . mysql_error()); } // Set up the database $db_select = mysql_select_db($this->db, $con); if(!$db_select) { die("ShadowCMS could not select a database: " . mysql_error()); } }

Now when i change it to this :

/* @function connect : This function will be used to establich a connection with the database. */ public function connect() { // Set up connection details for the site $con = mysqli_connect($this->host, $this->username, $this->password, $this->db); if (!$con) { die("ShadowCMS could not connect to the database: " . mysqli_error()); } }

It will always give back the error : database not selected.

How can I solve this ?

18 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Netherlands
black32 says

Here is a link to my question on stackoverflow.

by
by
by
by
by
by