I'm using this class for Database operations:
class DataBase
{
private $connect;
function __construct()
{
$this->connect();
}
function connect()
{
$this->connect = mysqli_connect(DB_NAME, DB_USER, DB_PASS, DB_NAME);
if(!$this->connect)
{
die('Connecting error: '.mysqli_error());
}
else
{
$select_db = mysqli_select_db($this->connect, DB_NAME);
if(!$select_db)
{
die('Database not exists!' .mysqli_error());
}
}
}
function query($sql)
{
return mysqli_query($this->connect, $sql);
}
}
$db = new DataBase();
It works perfect for getting information from DB, but not inserting it. :/
$connect = mysqli_connect(DB_NAME, DB_USER, DB_PASS, DB_NAME);
$sql = "INSERT INTO `users` (`login`, `password`, `email`, `name`) VALUES ('$_POST[login]', '$_POST[password]', '$_POST[email]', '$_POST[name]')";
$db->query($sql);
Even without a class it doesn't insert anything. Wtf?