How to understand single and double quotes in this method
PHP Code
db = Mysql::getins (); } User Registration method Public function Reg ($arr) { $sql = ' insert INTO '. $this->table. "(Username,passwd,email) VALUES ('"). $arr [' username ']. "','" . $arr [' passwd ']. "','" . $arr [' email ']. "')"; return $this->db->query ($sql); Print_r (Mysql_error ());} }
That SQL statement single double quotation marks no matter how to understand, forget friends troubleshoot!!!!!!!
------Solution--------------------
Do you understand if you write like this?
$sql = "INSERT INTO $this->table (username,passwd,email) VALUES (' $arr [username] ', ' $arr [passwd] ', ' $arr [email] ');
------Solution--------------------
You give the double quotes in SQL are the string definitions of PHP, and the single quotation marks are the SQL string definitions
------Solution--------------------
Yes. is to stitch it into a SQL string.
------Solution--------------------
discuss
PHP Code
Defined (' ACC ') | | Exit (' Access denied ');
Class Usermodel {
Protected $table = ' user ';
protected $db = false;
Public Function __construct () {
$this->db = Mysql::geti ...