1

生锈,只是试图通过参数传递东西。我究竟做错了什么?

//Insert into DB
function insert(x,y,z)
mysql_query("INSERT INTO x (y)
VALUES ('z')");


insert("test","name","Tyler");
4

2 回答 2

4
function insert($x,$y,$z){
    mysql_query("INSERT INTO ".$x." (".$y.") VALUES ('".$z."')");
}
insert("test","name","Tyler");
于 2012-07-22T20:37:46.283 回答
1

确保您通过以下方式正确引用变量$

//Insert into DB
function insert($x, $y, $z)
{
    mysql_query("INSERT INTO $x ($y) VALUES ('$z')");
}


insert("test","name","Tyler");
于 2012-07-22T20:38:50.687 回答