I can't save data to my database (mysql)


  • | 112 points

    This is my config to connect my localhost

    $c = new mysqli('localhost', 'root', '', 'data');
    

    And it's my code to save my data to database (mysql)

    <?php
    if(isset($_POST['save'])){
      $n = $_POST['fullname'];
      if(!empty($n)){
         $q = $c->query("INSERT INTO data VALUES('','$n')");
         if($q){
            header('location:index.php');
         }else{
           echo "Can't save data";
        }
      }
    }
    

    Database is connect but data can't save to database.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.