Something is wrong with my syntax. I am trying to use a php variable as the column name of the row I am currently reading. below is a snippet of my code. The first echo of folder properly displays for word "organizations" (the column name I want, and the last echo properly display the contents of the $row_ridoh['organization'] which is 1, but the echo in the middle with the variable coded does not work. Please advise.
while($row_ridoh = mysql_fetch_array($ridoh)) {
echo('folder: ' . $folder);
echo('heres the real PROBLEM: ' . $row_ridoh[${$folder}]);
echo('</br>row organizations: ' . $row_ridoh['organizations']);
if ($row_ridoh["{$folder}"] == '1') {
echo('keyword in if: ' . $folder);
}
}
I made the suggested changes to code:
while($row_ridoh = mysql_fetch_array($ridoh)){
echo('folder: ' . $folder);
echo('here the real PROBLEM: ' . $row_ridoh[$folder]);
echo('</br>row organizations: ' . $row_ridoh['organizations']);
if ($row_ridoh[$folder] == '1')
{ echo('keyword in if: ' . $folder); }
}
The echo for 'REAL PROBLEM" still not displaying. Here is my output when executed:
folder: organizations
Notice: Undefined index: organizations in /export/webs/inside.health/includes/sql/checkuser.php on line 30
here the real PROBLEM:
row organizations: 1
Again - thanks for the help. I updated the code to include the var_dump. It is listed below:
array(26) { [0]=> string(1) "1" ["id"]=> string(1) "1" [1]=> string(5) "admin" ["username"]=> string(5) "admin" [2]=> string(8) "r1health" ["password"]=> string(8) "r1health" [3]=> string(19) "2017-06-29 10:48:34" ["modified"]=> string(19) "2017-06-29 10:48:34" [4]=> string(1) "1" ["accomplishments"]=> string(1) "1" [5]=> string(1) "1" ["actions"]=> string(1) "1" [6]=> string(1) "1" ["complaints"]=> string(1) "1" [7]=> string(1) "1" ["diseases"]=> string(1) "1" [8]=> string(1) "1" ["entity"]=> string(1) "1" [9]=> string(1) "1" ["milestones"]=> string(1) "1" [10]=> string(1) "1" ["organizations"]=> string(1) "1" [11]=> string(1) "1" ["publications"]=> string(1) "1" [12]=> string(1) "1" ["specimens"]=> string(1) "1" }
It does have the column name correctly labeled as 'organizations'. The $folder variable is set in code above. As displayed in the echo output "folder: organizations".
Looking forward to other suggestions to try. Do you think it has anything to do with my version of php 5.1.6?