944,103 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1528
  • PHP RSS
Jul 1st, 2005
0

Function Problem. Please help

Expand Post »
This one isnt working!
PHP Syntax (Toggle Plain Text)
  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
PHP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bennetjosem is offline Offline
9 posts
since Sep 2004
Jul 1st, 2005
0

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]
Reputation Points: 36
Solved Threads: 6
Posting Whiz
Troy is offline Offline
354 posts
since Jun 2005
Jul 3rd, 2005
0

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";
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
senexom is offline Offline
54 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Money for Help
Next Thread in PHP Forum Timeline: Error with tables overlapping





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC