$sql=<<<EOF .... EOF;中,輸入sql語句,同時插入三條記錄,如想把密碼用md5加密,要如何做呢?
$sql=<<<EOF
INSERT user (username,password,email) VALUES("傅1", "'.md5('fhfjy').'","[email protected]"),
("傅2", "'.md5('fhfjy').'","[email protected]"),
("傅3", "'.md5('fhfjy').'","[email protected]")
EOF;
================================
插入后,去數據庫里看到的密碼是: ?'.md5('fhfjy').' ? 這樣的!
2015-03-15
用變量替代只能
^-^...
2016-04-09
2016-04-09
http://www.xianlaiwan.cn/qadetail/131282?t=158630#id_158630
$sql = <<<EOF
INSERT user(username,passwd) VALUES("u01","'.md5()'"),("u02","'.md5('pwd').'"),("u03","'.md5()'");
EOF;
EOF;// EOF; 結束符要頂格寫(前面不可以有空格?。?/p>
google:
http://stackoverflow.com/questions/20931450/parse-error-syntax-error-unexpected-t-sl
2016-04-09
<?php
// PDO
try{
?? ?$pdo = new PDO("mysql:host=localhost;dbname=test", 'root', '');
?? ?$sql = <<< EOF
?? ?INSERT user(username,passwd) VALUES("u01","'.md5()'"),("u02","'.md5('pwd').'"),("u03","'.md5()'");
?? ?EOF;
??? $result = $pdo->exec($sql);
}catch(PDOException $e){
?? ?echo $e->getMessage();
}
//To print a list of all the drivers that PDO currently supports, use the following code:
$xxx = var_dump(PDO::getAvailableDrivers());
echo ($xxx);
?>
2016-04-09
Parse error: syntax error, unexpected '<<' (T_SL) in G:\wwwRoot\php\pdo_md5.php on line 5