Linked Questions

Popular Questions

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'usr'@'localhost' (using password: YES) in /storage/emulated/0/htdocs/includes/condb.php on line 9 Failed to connect to MySql: Access denied for user 'usr'@'localhost' (using password: YES) Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /storage/emulated/0/htdocs/includes/condb.php on line 19

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /storage/emulated/0/htdocs/includes/condb.php on line 20 Unable to connect

Im trying to connect to the database using this code but im an unable to. I dont know what i actually did wrong. Ive tried googling and reading some articles but none of those work.

UPDATED CODE still getting the error message above.

 $server = "127.0.0.1"; $username = "usr"; $password = "123"; $database
= "contents";

 $conn = mysqli_connect($server,$username,$password,$database);
 if(mysqli_connect_errno($conn)) {
    echo "Failed to connect to MySql: ".mysqli_connect_error(); }

 $sql = "INSERT INTO contents('subj','article','day') VALUES
 ('".$_POST['This is the subj']."', '".$_POST['This is the
 content']."', '".$_POST['2019-02-01 10:15:59']."')";

 if(!mysqli_query($conn,$sql)) {
    die("Unable to connect".mysqli_error($conn)); }else {
    echo "Connected"; }

 ?>

Still getting the same error above unfortunately it was not a typo error. Still couldn't get the solution to this problem it has been days. Can someone with problem solving skills help me.

Related Questions