|
CamusHsu - 2017-06-20 06:09:46
Dear Sir,
I tried to insert one data as below,
$result = $db->query("INSERT INTO TB_USERS (NAME, ADDRESS, COMPANY) VALUES ('Evert Ulises German', 'Internet #996 Culiacan Sinaloa', 'Freelancer');");
I get bool(true) message, but the data doesn't insert into the database.
I tried another way to insert one data as below,
$result = $db->insert("TB_USERS", "NAME='Yusef German',ADDRESS='Tetameche #3035 Culiacan Sin. Mexico',COMPANY='Aluminium'");
It works well, so I can't use $db->query(insert......)?
Thank you!
CamusHsu
Evert Ulises German Soto - 2017-06-23 21:03:14 - In reply to message 1 from CamusHsu
Hi CamusHsu,
This way is more secure because with prepared statements you prevent sql injection.
$result = $db->query("INSERT INTO TB_USERS (NAME, ADDRESS, COMPANY) VALUES (?,?,?);", array('Evert Ulises German', 'Internet #996 Culiacan Sinaloa', 'Freelancer'));
You can check if return some error with:
echo $db->getError();
Best regards!
CamusHsu - 2017-06-29 08:20:00 - In reply to message 2 from Evert Ulises German Soto
Dear Sir,
Thank for your reply.
CamusHsu
|