CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [SOLVED]Problem with add textarea value

Print topic Send  topic

Author Message
fabiokbca

Posts: 18
Posted: 02/09/2012, 8:53 AM

Hi guys. Firstly sorry for my bad english.

I have a problem in before update/execute update event.
I need add in other table any information of textarea control. But $formname->$textareacontrolname->GetValue() don't work corretly.

My code is:

function f_Salvaanotacao(){ 	  
global $emprestimo;   
if (trim($emprestimo->txtAnotacao->GetValue()) != ""){  
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES (";   
$inserir .= CCGetFromGet("id_emprestimo") . ",";  
$inserir .= "'". $anotacao . "',";  
$inserir .= CCGetUserId() . ")";   
mysql_select_db('test');  
$inserir = mysql_query($inserir) or die(mysql_error()); 	  
}   
}

It is a first time i have a problem like this.

Someone can help me?
View profile  Send private message
andy


Posts: 183
Posted: 02/09/2012, 10:57 AM

If you use the CCToSQL(variable,ccsText) to encapsulate your variables, CCS will make them SQL friendly.
You can also define your connection as global, then open the connection, execute the defined insert query, then close the connection again.

How about this.:

  
function f_Salvaanotacao(){ 	    
  
global $DBConnection1; //Or use your connection name!!  
  
global $emprestimo;     
if (trim($emprestimo->txtAnotacao->GetValue()) != ""){    
  
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES ("     
.CCToSQL(CCGetFromGet("id_emprestimo"),ccsInteger).","  
.CCToSQL($anotacao,ccsText).","  
.CCToSQL(CCGetUserId(),ccsInteger).")";  
  
$db = new clsDBConnection1();   
$db->query($inserir);   
$db->close();  
}     
} 

_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
fabiokbca

Posts: 18
Posted: 02/10/2012, 3:26 AM

Hello
The $emprestimo->txtAnotacao->GetValue() returns ""
the query works well, only txtanotacao value dont work corretly.
View profile  Send private message
andy


Posts: 183
Posted: 02/10/2012, 4:52 AM

What data type is the value?
The available parameters for the CCToSQL(variable, type) are:
ccsDate, ccsBoolean, ccsInteger, ccsFloat, ccsText, ccsMemo

Are you sure that the value appears on the form as GetValue() only grabs the content of the field on the form in the browser...?

I think I can see where the error is (use $emprestimo as variable not $anotacao in sql statement) :

    
function f_Salvaanotacao(){ 	      
    
global $DBConnection1; //Or use your connection name!!    
    
global $emprestimo;       
if (trim($emprestimo->txtAnotacao->GetValue()) != ""){      
    
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES ("       
.CCToSQL(CCGetFromGet("id_emprestimo"),ccsInteger).","    
.CCToSQL($emprestimo,ccsText).","    
.CCToSQL(CCGetUserId(),ccsInteger).")";    
    
$db = new clsDBConnection1();     
$db->query($inserir);     
$db->close();    
}       
}

Better still...
May be you should set the variable first then use it. e.g.

    
function f_Salvaanotacao(){ 	      
    
global $DBConnection1; //Or use your connection name!!    
    
global $emprestimo;       
  
$var_anotacao = $emprestimo->txtAnotacao->GetValue();  
if (trim($var_anotacao) != ""){      
    
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario) VALUES ("       
.CCToSQL(CCGetFromGet("id_emprestimo"),ccsInteger).","    
.CCToSQL($var_anotacao,ccsText).","    
.CCToSQL(CCGetUserId(),ccsInteger).")";    
    
$db = new clsDBConnection1();     
$db->query($inserir);     
$db->close();    
}       
}

_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
fabiokbca

Posts: 18
Posted: 02/10/2012, 7:10 AM

Well. i will explain detailed my problem

My custom code works well if i remove if condition, but the value of textarea still empty.

Example in my db table when i run this custom code.

id_anotacao(PK) id_emprestimo(FK) descricao(control value) id_usuario(FK)
1 1 null 1

I'm tried like your suggestion but does not work corretly.
The text area control not return any value.
View profile  Send private message
fabiokbca

Posts: 18
Posted: 02/10/2012, 7:12 AM

SOrry for my first post. I made a mistake in $anotacao. Correct is $emprestimo->txtAnotacao->GetValue().
View profile  Send private message
fabiokbca

Posts: 18
Posted: 02/10/2012, 9:36 AM

I'm solved the problem.

I'm change textarea to textbox and my function work very well.
For test i change textbox to textarea control and work correctly again. Its very strange error but i'm solved with a very simple solution.
View profile  Send private message
andy


Posts: 183
Posted: 02/14/2012, 2:00 AM

Glad you found a solution.
;-)
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
clahti2

Posts: 107
Posted: 02/19/2012, 3:54 PM

ya, strange. So if I understand you correctly it didn't work when the control was a text area, but did work when you changed to textbox. AND finally continued to work after changing back to textarea? I am guessing there was a corrected typo somewhere in the iterations :-)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.