I am trying to make a 1 on 1 chat website by learning as I progress, but I've come to a hault.
I can't write to the database.
I have four php files linked below.
- Index
Init:
session_start(); define('LOGGED_IN', true); require 'classes/Core.php'; require 'classes/Chat.php'; ?>
Core:
class Core { protected $db, $result; private $rows; public function __construct() { $this->db = new mysqli("localhost","root",""); } public function query($sql) { $this->result = $this->db->query($sql); } public function rows() { for($x = 1; $x <= $this->db->affected_rows; $x++) { $this->rows[] = $this->result->fetch_assoc(); } return $this->rows; } } ?>
I have a MySql database set with WAMP.
P.S. Yes, I have opened the "< ? php" but it doesn't get displayed here.