Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-26-2011, 06:17 PM   PM User | #1
acemcleod
New to the CF scene

 
Join Date: Apr 2011
Location: Jacksonville
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
acemcleod is an unknown quantity at this point
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!
acemcleod is offline   Reply With Quote
Old 04-26-2011, 06:25 PM   PM User | #2
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
It would seem that the issuetableService object actually adds to / updates the database. We'd need to see the code for that object.
__________________
John
PappaJohn is offline   Reply With Quote
Old 04-26-2011, 07:19 PM   PM User | #3
acemcleod
New to the CF scene

 
Join Date: Apr 2011
Location: Jacksonville
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
acemcleod is an unknown quantity at this point
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;
  } 
acemcleod is offline   Reply With Quote
Old 04-27-2011, 03:22 AM   PM User | #4
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
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
PappaJohn is offline   Reply With Quote
Users who have thanked PappaJohn for this post:
acemcleod (04-29-2011)
Reply

Bookmarks

Tags
date, mysql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:30 PM.


Advertisement
Log in to turn off these ads.