javascript - MySQLi If condition alert msg not showing the output -


below given code working perfect. db table values inserted. echo message not showing in output

<?php  define('db_server', 'localhost'); define('db_username', 'root'); define('db_password', ''); define('db_database', 'admin'); $db = mysqli_connect(db_server,db_username,db_password,db_database); if(isset($_post["register"])) {     $id = $_post["id"];     $name = $_post["user_name"];     $password = $_post["password"];     $query = mysqli_query($db, "insert user (id, user_name, password)values ('$id', '$name', '$password')");     $result = mysqli_query($query);   if($result) {     echo "thank you! registered."; } } 

?>

you called mysqli_query 2 times , second time in wrong way, need call once instead

// change $query = mysqli_query($db, "insert user (id, user_name, password)values ('$id', '$name', '$password')"); $result = mysqli_query($query);  // $result = mysqli_query($db, "insert user (id, user_name, password) values ('$id', '$name', '$password')");  // , change condition  if( mysqli_affected_rows($db) ){  .. } 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -