[Gandi][Simple Hosting] Requête Mysqli

[Gandi][Simple Hosting] Requête Mysqli.
Select :
[php]
<?php
header("Cache-Control: max-age=1");
$host = "localhost";
$username = "<USERNAME>";
$password = "<PASSWORD>";
$dbname = "<DBNAME>";
$link = new mysqli($host, $username, $password, $dbname);
if (mysqli_connect_errno()) {
printf("Could not connect:: %s\n", mysqli_connect_error());
exit();
}
if ($result = mysqli_query($link, "SELECT * FROM wp_users")) {
echo "# Wordcodess user: ", mysqli_num_rows($result) . "<br/>";
echo "<table><tr><th>Login</th><th>Email</th></tr>";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<tr>";
echo "<td>" . $row["user_login"] . "</td><td>" . $row["user_email"] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_free_result($result);
}
mysqli_close($link);
?>
[/php]
Insert :
[php]
<?php
header("Cache-Control: max-age=1");
$host = "localhost";
$username = "<USERNAME>";
$password = "<PASSWORD>";
$dbname = "<DBNAME>";
$link = new mysqli($host, $username, $password, $dbname);
if (mysqli_connect_errno()) {
printf("Could not connect:: %s\n", mysqli_connect_error());
exit();
}
if (!($query = $link->codepare("INSERT INTO wp_users(user_login,user_email) VALUES (‘test’, ‘test@gmail.com’)"))) {
echo "Execute failed : (" . $link->errno . ") " . $link->error;
}
if (!$query->execute()) {
echo "Execute failed : (" . $link->errno . ") " . $link->error;
}
mysqli_close($link);
?>
[/php]

Comments are closed, but trackbacks and pingbacks are open.