Help me inspect this code.
I cannot see error by myself.
here are the codes for inc.database.php
I'm learning OOP with PHP (I extensively using it with python but I'm noob to PHPiing)
<?php
class Connectdb{
private $DATABASE = "site_contents";
private $HOST = "localhost";
private $USER = "root";
private $PASS = "jesus";
public function __construct(){}
public function connect($host = $HOST, $user = $USER = "root", $passwd = $PASS, $db = $DATABASE ){
$conn = mysql_connect($host, $user, $passwd) or die("Cannot Connect to the database $db");
mysql_select_db($db, $conn) or die("Unable to select database");
return $conn;
}
public function insertdata($conn, $array_values){
//array should have id, update_date , description , heading , contents, creator
if (isset(_POST["save"])){
$query = 'INSERT INTO articles(id, date_date , description , heading , contents, creator) VALUES($array_values['id'], $array_values['update_date'], $array_values['description'], $array_values['heading'], $array_values['contents'], $array_values['creator'])';
if(mysql_query($query){
echo "Successful Inserted!";
header('Location:/site/view.php');
die("Illegal action, contact admin!");
}
}
}
public function retrievedata($conn, $table){
$query = 'SELECT * FROM $table';
$result = mysql_query($query);
$row = mysql_fetch_object($result);
return $row;
}
}
?>