不使用PHP插入/更新表

时间:2019-04-21 18:14:39

标签: php mysqli insert

我正在尝试以以下形式插入一些数据(名称,电子邮件,密码) 但是当我在数据库中打开表时,未插入数据.. 有任何想法吗 ?非常感谢您的帮助。

<?php

$link = mysqli_connect("localhost", "root" ,"","myDemo");


    if(mysqli_connect_error()){
        
        die("Failed to connect to database ");
    }

$query = "INSERT INTO 'users' ('name' , 'email' , 'password') VALUES ('john' , 'john@gmail.com' , '123')";

mysqli_query($link,$query);

// below this line works fine which retrieve the first row in the table

$query = "SELECT * FROM users";

if($res = mysqli_query($link,$query)){
    
    $row = mysqli_fetch_array($res);
    echo "ID: " .$row['id']. "<br> Name: " .$row['name'] ."<br> Email: " . $row['email'] ."<br> Passwoord:" .$row['password'];
    
}
else echo "false";


?>

0 个答案:

没有答案