What is the problem with php operating the database?

$sql = "insert into user (account,password,mail,phone,) VALUES (". $account.",".$password.",".$mail.",".$phone.")";

$query = $this- > link- > query ($sql);
when inserting data into the database, the VALUES parentheses should be written in the form of variables. Is this correct?

Php
Mar.06,2021

check the representation of PHP strings, the difference between single and double quotes


$sql = "insert into user(account,password,mail,phone) VALUES ('".$account."','".$password."','".$mail."','".$phone."')";

suggest that you use sprintf, to be more intuitive


  

single quotation marks do not resolve variables, double quotation marks resolve variables, just replace single quotation marks with double quotation marks

Menu