I have a table called cms_settings. I name all the tabels with a prefix cms_ so i created a variable $dbpraefix="cms_"
when i call the entry using "select value from $dbpraefix.settings" command, it failed to proceed.
i also tried defferent version. like "select from '.$dbpraefix.'settings etc. nothing works.
but if i use "select value from cms_settings instead, it works!. how can i fix this. thanks a lot
<?PHP
function getSetting($property){
global $connection;
$dbpraefix= "cms_";
$sql= "SELECT value FROM $dbpraefix.settings WHERE property='$property'";
$ergebnis= mysqli_query($connection, $sql);
$row = mysqli_fetch_row($ergebnis);
return $row[0];
}
?>
mysqliyou should be using parameterized queries andbind_paramto add user data to your query. DO NOT use string interpolation or concatenation to accomplish this because you have created a severe SQL injection bug. NEVER put$_POSTor$_GETdata directly into a query, it can be very harmful if someone seeks to exploit your mistake.