Function Problem. Please help

Reply

Join Date: Sep 2004
Posts: 9
Reputation: bennetjosem is an unknown quantity at this point 
Solved Threads: 0
bennetjosem bennetjosem is offline Offline
Newbie Poster

Function Problem. Please help

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

But this one Works
  1. echo " <td colspan=\"3\" align=\"left\"> <br>\n";
  2. echo " <b>Date Published</b>:",$Date_Added[$num] ,"<br>\n";
  3. 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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Function Problem. Please help

 
0
  #2
Jul 1st, 2005
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]
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 54
Reputation: senexom is an unknown quantity at this point 
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: Function Problem. Please help

 
0
  #3
Jul 3rd, 2005
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";
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC