I am getting a value for return instead of getting my data from my database. The code should be good. Here is my code:

function getConfigurationData($configuration_value, $configuration_name_value) {
$sql = "SELECT '".$configuration_value."' FROM configuration WHERE name = '".$configuration_name_value."'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo $row[$configuration_value];

<? getConfigurationData("value", "configuration_website_name"); ?>

What is wrong with my configuration. I seem not be returning my data and instead I get a value

Was it helpful?


your query is wrong (quotes around field name)

Try this

$sql = "SELECT ".$configuration_value." FROM configuration WHERE name = '".$configuration_name_value."'";

and a more readable way

$sql = "SELECT $configuration_value FROM configuration WHERE name = '$configuration_name_value'";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top