I know this is right /MYSQL query results/PHP ECHO
Posted: Fri Dec 26, 2003 5:28 am
I am having a problem with passing the results of a MYSQL query to a PHP function and i know for a fact that i have it correct, because it works in one case but not in a second identical case(copy and pasted code). I have three files, index.php, menu.php, and contentmenu.php. index.php includes bother of the other two files and i know that they are bothing being includeed and thier respective functions are being called based on static HTML output.
I will post the jist of my files, excluding info that is not nessessary.
index.php
menu.php
content_subsection_menu.php
The firstone outputs correctly, outputing the text "subsection"
now the 2nd one prints nothing, not even an error code. When i try to echo w/o fetching the array, it gives me a reasource ID # 12 or something.
I see no reason that this should not work. I have many other things that doe not work. I am able to echo other variables that are passed to the function. I just cant seam to get this to work.
what i might do is to write a function that is independent of the HTML code around it, and that jsut echos the data, and then i could jsut call that, but i would rather have it work this way, and i know that this is a run on sentence, and i know there are alot of spe;lling errors, but it is really late and i am really tired.
Hope that this made since.
Thanks
I will post the jist of my files, excluding info that is not nessessary.
index.php
Code: Select all
include("../assets/php/menu/menu.php");
include("../assets/php/menu/content_subsection_menu.php");
$currentSectionID = getSectionID();
$subsection_query = "SELECT * FROM subsection WHERE id = '$currentSectionID'";
$subsection_results = dbquery($subsection_query);
genCurrentSubMenu($siteURL, $TESTCSS, $currentSection, $currentSubSection, $subsection_results);
//THIS WORKS EXACTLY AS IT SHOULD
genSubContentMenu($siteURL, $TESTCSS, $currentSection, $currentSubSection, $subsection_results);
//THIS DOES NOT WORK AT ALLCode: Select all
function genCurrentSubMenu($siteURL, $TESTCSS, $currentSection, $currentSubSection, $subsection_results)
{
HTML
while($subsection_data = mysql_fetch_array($subsection_results))
{
echo "$subsection_data[subsection]";
}
}Code: Select all
function genSubContentMenu($siteURL, $TESTCSS, $currentSection, $currentSubSection, $subsection_results)
{
HTML
while($subsection_data = mysql_fetch_array($subsection_results))
{
echo "$subsection_data[subsection]";
}
}now the 2nd one prints nothing, not even an error code. When i try to echo w/o fetching the array, it gives me a reasource ID # 12 or something.
I see no reason that this should not work. I have many other things that doe not work. I am able to echo other variables that are passed to the function. I just cant seam to get this to work.
what i might do is to write a function that is independent of the HTML code around it, and that jsut echos the data, and then i could jsut call that, but i would rather have it work this way, and i know that this is a run on sentence, and i know there are alot of spe;lling errors, but it is really late and i am really tired.
Hope that this made since.
Thanks