in php the value keep - undefine help me pls!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rocky86
    New Member
    • Jun 2007
    • 93

    in php the value keep - undefine help me pls!!

    hi people basically I am having a problem with the followinng code:
    [PHP]
    $names=sizeof($ temp);
    $report="total= $names&";

    foreach($temp as $list)
    $report.="name" .$names--."=".$list." &";


    echo $report;
    [/PHP]

    from the above code the "total" is always undefine when I try to output it even when I put "total =3" anybody know or there is something wrong with my code pls help thx~
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    [PHP]$names=sizeof($ temp);
    $report="total= $names&";
    foreach($temp as $list)
    $report.="name" .$names--."=".$list." &";
    echo $report;[/PHP]
    from the above code the "total" is always undefine
    I think in this instance php is treating total as a CONSTANT and not as a string..
    You have to define a CONSTANT.
    This code looks a real mess. What are youu trying to achieve?

    Comment

    • Rocky86
      New Member
      • Jun 2007
      • 93

      #3
      Originally posted by code green
      [PHP]$names=sizeof($ temp);
      $report="total= $names&";
      foreach($temp as $list)
      $report.="name" .$names--."=".$list." &";
      echo $report;[/PHP]

      I think in this instance php is treating total as a CONSTANT and not as a string..
      You have to define a CONSTANT.
      This code looks a real mess. What are youu trying to achieve?
      hi you mention I have to define a CONSTANT what do you mean ? basically I am trying to store the number of name inside the variable name total and pass it to the actionsript to output it

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        So the output of the PHP code is being received by your Actionscript, which is unable to parse the "total=3" into a value?

        There is nothing wrong with the PHP, this sounds like an actionscript problem.

        Comment

        • Rocky86
          New Member
          • Jun 2007
          • 93

          #5
          Originally posted by Atli
          So the output of the PHP code is being received by your Actionscript, which is unable to parse the "total=3" into a value?

          There is nothing wrong with the PHP, this sounds like an actionscript problem.
          hi can anyone explain to me what is this part of the code doing?
          [PHP]
          $report.="name" .$names--."=".$list." &";


          [/PHP]

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            can anyone explain to me what is this part of the code doing?
            [PHP]$report.="name" .$names--."=".$list." &";[/PHP] It is concatenating the following string onto the current value of $report
            Code:
            the word "name" + the value of $names-- + equals sign("=") + value of $list + ampersand ("&")

            Comment

            Working...