I face problem while connecting to database. always getting message ( "message":"Unable to save the data to the database." ) when i execute register to my local server.
register.php
<?php
error_reporting(0);
require "init.php";
$fname = $_POST["name"];
$lname = $_POST["password"];
$qualifiers = $_POST["qualifiers"];
$signature = $_POST["signature"];
$sql = "INSERT INTO user_info (id,Fname, Lname, Qualifiers, SigNature) VALUES (NULL, '".$fname."', '".$lname."', '".$qualifiers."', '".$signature."');";
if(!mysqli_query($con, $sql)){
echo '{"message":"Unable to save the data to the database."}';
}
?>
init.php
<?php
error_reporting(0);
$db_name = "app";
$mysql_user = "root";
$mysql_pass = "";
$server_name = "localhost";
$con = mysqli_connect($server_name, $mysql_user, $mysql_pass, $db_name);
if(!$con){
echo '{"message":"Unable to connect to the database."}';
}
?>