hey... found this website when googling for a php help forum... hopefully this is the right place.
I am about to start a major project for a new high profile company contract my company is presently bidding on. One of the requirements is a web interface to communicate between the 2 companies.
I recently read (and have been reading more into it) that MDB2 is (one of) the best methods to communicate with a database (using prepared statements).
It seems to be extremely popular, and not to difficult to use... however, for some reason, it just wont work for me.
<?php
require_once '/include/MDB2.php';
function connect(){
$SQL = array(
'driver' => 'mysql',
'user' => '***',
'pass' => '***',
'host' => '127.0.0.1',
'dbname' => '***',
);
$SQL['sql'] = $SQL['driver']."://".$SQL['user'].":".$SQL['pass']."@".$SQL['host']."/".$SQL['dbname'];
$mdb2 = MDB2::connect($SQL['sql']);
$mdb2->setOption('emulate_prepared',true);
if(PEAR::isError($mdb2))die("Error while connecting : " . $mdb2->getMessage());
return $mdb2;
}
$mdb2 = connect();
$statement = $mdb2->prepare("INSERT INTO `test` (id,name) VALUES (?, ?)", array('integer','text'), MDB2_PREPARE_MANIP);
$statement->execute(array(1,'someuser'));
$statement->free();
?>
For some reason, this is not working? However if I just execute a normal query, it works no problem:
<?php
$mdb2 = connect();
$statement = $mdb2->query("INSERT INTO `test` (id,name) VALUES (1,'someuser')");
?>
So, I am connecting properly, everything is good... but this prepared statement just hates me Any help please?