生锈,只是简单地试图通过参数传递东西。我究竟做错了什么?
//Insert into DB
function insert(x,y,z)
mysql_query("INSERT INTO x (y)
VALUES ('z')");
insert("test","name","Tyler");
答案 0 :(得分:4)
function insert($x,$y,$z){
mysql_query("INSERT INTO ".$x." (".$y.") VALUES ('".$z."')");
}
insert("test","name","Tyler");
答案 1 :(得分:1)
确保通过$
正确引用变量:
//Insert into DB
function insert($x, $y, $z)
{
mysql_query("INSERT INTO $x ($y) VALUES ('$z')");
}
insert("test","name","Tyler");