PHP函数变量传递
问题描述:
Rusty, just simply trying to pass stuff through parameters. What am I doing wrong?
//Insert into DB
function insert(x,y,z)
mysql_query("INSERT INTO x (y)
VALUES ('z')");
insert("test","name","Tyler");
生锈,只是简单地尝试通过参数传递内容。 我究竟做错了什么? p>
//插入DB
function insert(x,y,z)
mysql_query(“INSERT INTO x(y)
VALUES('z')”); \ n
insert(“test”,“name”,“Tyler”);
code> pre>
div>
答
function insert($x,$y,$z){
mysql_query("INSERT INTO ".$x." (".$y.") VALUES ('".$z."')");
}
insert("test","name","Tyler");
答
Be sure you are referencing the variable correctly via $
:
//Insert into DB
function insert($x, $y, $z)
{
mysql_query("INSERT INTO $x ($y) VALUES ('$z')");
}
insert("test","name","Tyler");