www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Fatal error: Function name must be a string in C:\wamp\www\test\mylabel.php on line 7

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Location
    Andrews, SC
    Posts
    7

    resolved [RESOLVED] Fatal error: Function name must be a string in C:\wamp\www\test\mylabel.php on line 7

    I'm clearly doing something wrong. I ported this piece of code from one I wrote in VBScript (where it works great), but I'm not as familiar with php syntax. Hopefully you can see where I'm going with this. I want to end up with a variable that contains the string of Sh0413C

    Code:
    $monthCode = array("02", "03", "04", "06", "09", "10", "10", "11", "11", "12", "12", "01");
    $monthLetterCode = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M");
    
    $realMonthCode = date("n"); 
    $labelYearCode = date("y");
    $arrayMonthCode = $realMonthCode - 1;
    $labelMonthCode = $monthCode(arrayMonthCode);
    $labelLetterCode = $monthLetterCode(arrayMonthCode);
    $myString = "Sh" . $labelMonthCode . $labelYearCode . $labelLetterCode;

  2. #2
    Join Date
    Mar 2013
    Location
    Andrews, SC
    Posts
    7

    resolved

    This has been resolved. The 2 instances of (arrayMonthCode) needed to be [$arrayMonthCode]

    Code:
    $monthCode = array("02", "03", "04", "06", "09", "10", "10", "11", "11", "12", "12", "01");
    $monthLetterCode = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M");
    
    $realMonthCode = date("n"); 
    $labelYearCode = date("y");
    $arrayMonthCode = $realMonthCode - 1;
    $labelMonthCode = $monthCode[$arrayMonthCode];
    $labelLetterCode = $monthLetterCode[$arrayMonthCode];
    $myString = "Sh" . $labelMonthCode . $labelYearCode . $labelLetterCode;

  3. #3
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    You're trying to use the variable for the monthCode array as a function instead of an array. The following 2 lines need changed:

    PHP Code:
    $labelMonthCode $monthCode(arrayMonthCode);
    $labelLetterCode $monthLetterCode(arrayMonthCode);

    // Change them to:
    $labelMonthCode $monthCode[$arrayMonthCode];
    $labelLetterCode $monthLetterCode[$arrayMonthCode]; 
    Edit: Looks like you found it already. Sorry I wasn't helpful
    ~Ryan
    www.rdennispallas.com <-- Personal Site, changing regularly cuz its ugly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles