Forum Moderators: coopster
<?
$mysqli = @new mysqli('localhost', 'xxxxx', 'xxx', 'table');
$mysqli->set_charset("utf8");
if ($mysqli->connect_error)
{
die('There is a temporary problem with this page at this moment: ' . $mysqli->connect_error);
}
include 'conexionmysqli.php';
$emailtrue = 'test';
$orderdatetime= '2014-01-21';
$statement = 'notpaid';
$query = $mysqli->prepare ("insert into orders (emailtrue, orderdatetime, statement) values (?, ?, ?)");
/* Bind parameters
s - String, b - Boolean, i - Integer etc, d - DOUBLE and FLOAT*/
$query->bind_param("sss", $emailtrue, $orderdatetime, $unpaid);
$query->execute();
$query->close();
?> $stmt = $mysqli->prepare ("insert into orders (emailtrue, orderdatetime, statement, concepto) values (?, ?, ?,?)");
/* Bind parameters
s - String, b - Boolean, i - Integer etc, d - DOUBLE and FLOAT*/
$stmt->bind_param("ssss", $emailtrue, $orderdatetime, $unpaid, $concepto);
$stmt->execute();
didnīt know had to use stmp
$myVar = $mysqli->prepare(....);
$myVar->bind_param(....);
$myVar->execute();
//prepared insert
$emailtrue = 'tres';
$name='t';
$concepto='r';
$telhome='p';
$telmobile='k';
$holidaycost='l';
$sentencia = $dbh->prepare("INSERT INTO ordered (emailtrue, orderdatetime, statement, name, concepto, telhome, telmobile, holidaycost) VALUES (:emailtrue, NOW(), 'unpaid', :name, :concepto, :telhome, :telmobile, :holidaycost)");
$sentencia->bindParam(':emailtrue', $emailtrue);
$sentencia->bindParam(':name', $name);
$sentencia->bindParam(':concepto', $concepto);
$sentencia->bindParam(':telhome', $telhome);
$sentencia->bindParam(':telmobile', $telmobile);
$sentencia->bindParam(':holidaycost', $holidaycost);
// insertar una fila
$sentencia->execute();
print $dbh->lastInsertId();
// create prepared statement and update
$id = $dbh->lastInsertId();
echo $id;
$sql = $dbh->prepare ("UPDATE ordered SET id='pay$id' WHERE order_id = :id");
$sql->bindParam(':id', $id);
$sql->execute(); [edited by: helenp at 9:57 pm (utc) on Jan 26, 2014]
$id='pay455';
$query = $dbh->query("
SELECT id, order_id FROM ordered WHERE id = :id");
// fetch row
// execute statement, binding values to the parameters
$query->execute(array(
'id' => $id
));
foreach ($query as $row) {
echo html_escape('Post ' . $row['id'] . ' from ' . $row['order_id']) . '<br/>';
}