简体   繁体   中英

Issue with PHP not allowing multiple function parameters

is there an issue with PHP not allowing multiple function parameters and returning the correct value. Here is the code:

function getConfig($name) {
$sql = "SELECT value FROM config WHERE name = '".$name."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
print $row["value"];
} 

getConfig("name");

While the code above works, the code bellow similar does not work. Here is the code:

function getConfig($name, $from) {
$sql = "SELECT value '".$from."' config WHERE name = '".$name."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
print $row["value"];
} 

getConfig("name", "config");

Why does that occur that the 1st function works and the second does not?

$sql = "SELECT value FROM '".$from."' WHERE name = '".$name."'";
//                   FROM TABLE_NAME
//           and not TABLE_NAME TABLE_NAME

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM