fabiokbca
Posts: 18
|
Posted: 02/27/2012, 8:57 AM |
|
Hi guys;
My custom insert dont work.
It work one time but work no more.
function emprestimo_ds_BeforeExecuteUpdate(& $sender) {
$emprestimo_ds_BeforeExecuteUpdate = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $emprestimo; //Compatibility //End emprestimo_ds_BeforeExecuteUpdate
//Custom Code @50-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
// ADICIONAR ANOTACAO
$anotacao = $emprestimo->txtAnotacao->GetValue(); //die($anotacao);
if (trim($anotacao != "")){
$inserir = "INSERT INTO anotacoes (id_emprestimo, descricao, id_usuario, data_hora) VALUES (";
$inserir .= CCGetFromGet("id_emprestimo") . ",";
$inserir .= "'". $anotacao . "',";
$inserir .= CCGetUserId() . ",'" . date("Y-m-d H:i:s") . "')"; //$inserir = mysql_query($inserir) or die(mysql_error());
// WHY THIS LINE DONT WORK WHEN MY PROJECT NOT IN LOCAL MACHINE?
$db = new clsDBConnection1;
$db->query($inserir);
$db->close;
}
Anybody can help me?
|
|
|
Gena
Posts: 591
|
Posted: 02/27/2012, 9:17 AM |
|
add code like
echo $inserir;
to see what INSERT was generated, if sintax is correct....
_________________
Gena |
|
|
fabiokbca
Posts: 18
|
Posted: 02/27/2012, 9:54 AM |
|
Hello Gena. Sintax is correct. See "die($inserir);"
I'm test the sql string in phpmyadmin and work correctly.
|
|
|
fabiokbca
Posts: 18
|
Posted: 02/27/2012, 9:57 AM |
|
I don't now what is happening. In a moment dont work, few minutes later work correctly with the same sql string. Code Charge make me crazy
|
|
|
clahti2
Posts: 107
|
Posted: 02/27/2012, 3:37 PM |
|
this sounds like it may be an uncaptured SQL exception, why don't you see if there is an SQL error, try something like (assuming MySQL):
die ("Query failed: " . mysql_error() . " Actual query: " . $query);
|
|
|
|