DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   Function Problem. Please help (http://www.daniweb.com/forums/thread27087.html)

bennetjosem Jul 1st, 2005 4:26 am
Function Problem. Please help
 
This one isnt working!
function insertpath($num){
echo "          <td colspan=\"3\" align=\"left\"> <br>\n";
echo "              <b>Date Published</b>:",$Date_Added[$num] ,"<br>\n";
echo "              <b>Sample</b>:",$Sample_Views[$num],"</td>\n";
}
insertpath(0);

But this one Works
echo "          <td colspan=\"3\" align=\"left\"> <br>\n";
echo "              <b>Date Published</b>:",$Date_Added[$num] ,"<br>\n";
echo "              <b>Sample</b>:",$Sample_Views[$num],"</td>\n";

Well not woking in the sense the values of variables ($Date_Added[$num],$Sample_Views[$num]) not coming in the first. Whil in second its working!


Help me :(

Troy Jul 1st, 2005 9:11 am
Re: Function Problem. Please help
 
There are two things you need to do to troubleshoot this problem. INSIDE your function, at the very top, do this:

First, echo out one of the arrays like this:
[PHP]
echo "<pre>";
print_r($Date_Added);
echo "</pre>";
[/PHP]

Then echo out the value of $num:
[PHP]
echo "<hr />".$num;
[/PHP]

You should see that $num = 0, but that your array does not even exist. You forgot one important line at the top of your function:
[PHP]
global $Date_Added, $Sample_Views;
[/PHP]

senexom Jul 3rd, 2005 3:13 pm
Re: Function Problem. Please help
 
Maybe concat syntax error :o

THIS....
echo "<b>Sample</b>:",$Sample_Views[$num],"</td>\n";

SHOULD BE THIS....
echo "<b>Sample</b>:".$Sample_Views[$num]."</td>\n";


All times are GMT -4. The time now is 11:09 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC