mysql - Php PDO, Insert a changable varible -
test website: csgodice.co.uk
i've been looking pdo, confuses me, 14 , im not knowledge mysql in php know use pdo , parts of databases, wondering how insert changable value, such balance, here information want insert table rows
$conn->prepare("insert users (64id, balance, amountbet) values (?, ?, ?)"); $stmt->bind_param("sss", $64id, $balance, $amountbet ); // set parameters , execute $_64id = "$steamprofile['steamid']"; $balance = ""; $amountbet = ""; $stmt->execute();
i have connected mysql done, need know how insert rows? know there documentation topics on there differ trying do?
take php documentation http://php.net/manual/en/pdostatement.bindparam.php
<?php /* execute prepared statement binding php variables */ $calories = 150; $colour = 'red'; $sth = $dbh->prepare('select name, colour, calories fruit calories < :calories , colour = :colour'); $sth->bindparam(':calories', $calories, pdo::param_int); $sth->bindparam(':colour', $colour, pdo::param_str, 12); $sth->execute(); ?>
so code be:
$stmt = $conn->prepare("insert users (64id, balance, amountbet) values (:_64id, :balance, :amountbet)"); $_64id = $steamprofile['steamid']; $balance = ""; $amountbet = ""; $stmt->bind_param(:_64id, $_64id); $stmt->bind_param(:balance, $balance); $stmt->bind_param(:amountbet, $amountbet); $stmt->execute();
Comments
Post a Comment