php and mysql -> NO ERROR BUT NO INSERT

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
redbean
Forum Newbie
Posts: 2
Joined: Sun Nov 29, 2009 9:09 am

php and mysql -> NO ERROR BUT NO INSERT

Post by redbean »

hi, i'm new

i'm going crazy with an error that not results.
this is my php code:

// begin transaction without autocommit
try {
GestoreDB::getInstance()->beginTransaction('void');
} catch (PDOException $e) {
echo '<p class="error">Connection failed</p>';
}


// construct query, prepare statement and bind parameters
$sQuery = "INSERT INTO Annuncio (data_insert, titolo, municipio, indirizzo, prezzo, locali, bagni, superficie, riscaldamento, cucina, balcone, piano, piani_tot, ascensore, box, descr) values (:data_insert, :titolo, :municipio, :indirizzo, :prezzo, :locali, :bagni, :superficie, :riscaldamento, :cucina, :balcone, :piano, :piani_tot, :ascensore, :box, :descr)";
$stmtAnn = GestoreDB::getInstance()->preparePDOStatement($sQuery);
$date = 'CURDATE()';
$stmtAnn->bindParam(':data_insert', $date);
$stmtAnn->bindParam(':titolo', GestoreFunzioni::getInstance()->codificaForDB($_POST['titolo']));
$stmtAnn->bindParam(':municipio', GestoreFunzioni::getInstance()->codificaForDB($_POST['municipio']));
$stmtAnn->bindParam(':indirizzo', GestoreFunzioni::getInstance()->codificaForDB($_POST['indirizzo']));
$stmtAnn->bindParam(':prezzo', $_POST['prezzo']);
$stmtAnn->bindParam(':locali', $_POST['locali']);
$stmtAnn->bindParam(':bagni', $_POST['bagni']);
$stmtAnn->bindParam(':superficie', $_POST['superficie']);
$stmtAnn->bindParam(':riscaldamento', $_POST['riscaldamento']);
$stmtAnn->bindParam(':cucina', $_POST['cucina']);
$stmtAnn->bindParam(':balcone', $_POST['balcone']);
$stmtAnn->bindParam(':piano', $_POST['piano']);
$stmtAnn->bindParam(':piani_tot', $_POST['piani_tot']);
$stmtAnn->bindParam(':ascensore', $_POST['ascensore']);
$stmtAnn->bindParam(':box', $_POST['box']);
$stmtAnn->bindParam(':descr', GestoreFunzioni::getInstance()->codificaForDB($_POST['descr']));

// execute statement
GestoreDB::getInstance()->executePDOStatement($stmtAnn);
echo 'erroreCode = ' . $stmtAnn->errorCode();


if i execute this, i don't retrieve any error. my output is

erroreCode = 00000

i go to db, i interrogate it and i discover nothing inserted.
i've checked manually connection changing password and i retrieve ar access error.
if i copy my query and paste it into sql terminal all works.

what's happening?

thanks

--
redbean
redbean
Forum Newbie
Posts: 2
Joined: Sun Nov 29, 2009 9:09 am

Re: php and mysql -> NO ERROR BUT NO INSERT

Post by redbean »

Sorry,
resolved. I forgot to committ the transaction :banghead:

bye bye
Post Reply