Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Location
    Jacksonville
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post Passing the result of a function to mysql

    Hello folks, generally I prefer to find my answers via google or use help files but so far can't find anything to help me on this. For reference sake I am heavily modifying the Flex Test Drive App since it pretty much facilitates what I am trying to do, which is build an issue tracking application for my company. Its not software, more like customer calls to complain about something. Anyhow, I have created an InputDate field that I have written a function to populate with the currentDate, however the value of the function is not being passed to the database. How do I get a value generated by a function to post to a mysql database?


    Code:
    //Here is the function that adds issues to the database
    protected function button_clickHandler(event:MouseEvent):void
     {
      issues.iDate = iDateTextInput.text;
      issues.customerFname = customerFnameTextInput.text;
      issues.customerLname = customerLnameTextInput.text;
      issues.phNum = phNumTextInput.text;
      issues.customerAddress = customerAddressTextInput.text;
      issues.customerCity = customerCityTextInput.text;
      issues.customerState = customerStateTextInput.text;
      issues.iType = iTypeTextInput.text;
      issues.iNote = iNoteTextInput.text;
      issues.binQ = binQTextInput.text;
      issues.dDate = dDateTextInput.text;
      issues.rtNum = rtNumTextInput.text;
      issues.rtSupervisor = rtSupervisorTextInput.text;
      issues.iClosed = iClosedTextInput.text;
      issues.rDate = rDateTextInput.text;
      issues.rNote = rNoteTextInput.text;
    		
    if(issues.tktNum==0){
     createIssuetableResult.token = issuetableService.createIssuetable(Issues);
    }
    else{
     updateIssuetableResult.token = issuetableService.updateIssuetable(Issues);
      }
    }
    
    //Function to get today's date and return a string
    private function currentDateToString():String{
                  var CurrentDate:Date = new Date();
    	      return dateFormatter.format(CurrentDate);
    }
    
    //This is the specific form label that displays the result of the function
    <mx:FormItem label="Input Date:">
    	<s:Label id="iDateTextInput" text="currentDateToString()}"/>
    </mx:FormItem>
    I appreciate any help. Thanks!

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    It would seem that the issuetableService object actually adds to / updates the database. We'd need to see the code for that object.
    John

  • #3
    New to the CF scene
    Join Date
    Apr 2011
    Location
    Jacksonville
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Here is the php function that is used to create the issue

    PHP Code:
    public function createIssuetable($item) {
            
    $stmt mysqli_prepare($this->connection,
                
    "INSERT INTO issuetable (
                    iDate, customerFname, customerLname,
                            phNum, customerAddress, customerCity,
                            customerState, iType, iNote, rNote, rDate,
                            rtNum, binQ, dDate, iClosed, rtSupervisor) 
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
    );
            
    $this->throwExceptionOnError();
        
            
            
    mysqli_bind_param($stmt'sssssssssssiisss'$item->iDate$item->customerFname$item->customerLname,
                                                      
    $item->phNum$item->customerAddress$item->customerCity,
                                                      
    $item->customerState$item->iType$item->iNote$item->rNote,
                                                      
    $item->rDate$item->rtNum$item->binQ$item->dDate$item->iClosed$item->rtSupervisor);
            
    $this->throwExceptionOnError();
        
        
            
    mysqli_stmt_execute($stmt);
            
    $this->throwExceptionOnError();
        
            
            
    $autoid mysqli_stmt_insert_id($stmt);
        
            
            
    mysqli_stmt_free_result($stmt);
            
    mysqli_close($this->connection);
            
            return 
    $autoid;
      } 

  • #4
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Well that's great, but not quite what I asked for - no matter, I just noticed the probable culprit.

    Code:
    if(issues.tktNum==0){
     createIssuetableResult.token = issuetableService.createIssuetable(Issues);
    }
    else{
     updateIssuetableResult.token = issuetableService.updateIssuetable(Issues);
      }
    }
    Note the items in red. AS is case-sensitive, issues is not the same as Issues. I'm thinking you want:
    Code:
    if(issues.tktNum==0){
     createIssuetableResult.token = issuetableService.createIssuetable(issues);
    }
    else{
     updateIssuetableResult.token = issuetableService.updateIssuetable(issues);
      }
    }
    John

  • Users who have thanked PappaJohn for this post:

    acemcleod (04-29-2011)


  •  

    Tags for this Thread

    Posting Permissions

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