若本功能保存的值:直接参数VS.在变量
function get_article_info(){
$id = $_GET['id'];
$data = array();
$q = "SELECT * FROM articles WHERE article_id = $id";
$qry = mysql_query($q);
while($row = mysql_fetch_assoc($qry)){
$data[] = $row;
}
return $data;
}
是相同的,因为这一个:
function get_article_info2(){
$id = $_GET['id'];
$data = array();
$q = mysql_fetch_assoc(mysql_query("SELECT * FROM articles WHERE article_id = $id"));
while($row = $q){
$data[] = $row;
}
return $data;
}
如果我尝试使用get_article_info2我得到这个错误:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes)
灿任何告诉我为什么它不工作? THX)
你真的不应该使用'mysql_ *'函数,因为它们已被废弃,不再支持,请查看** PDO **或** mysqli **而不是 – Pankucins 2013-04-09 13:24:28