MySQLi Procedural
Simple connection to the database using this extension mysqli.
<?php
$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));
$query = "SELECT name FROM mytable" or die("Error in the consult.." . mysqli_error($link));
$result = $link->query($query);
while($row = mysqli_fetch_array($result)) {
echo $row["name"] . "<br>";
}
?>
or
<?php
$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));
$query = "SELECT name FROM mytable" or die("Error in the consult.." . mysqli_error($link));
$result = mysqli_query($link, $query);
while($row = mysqli_fetch_array($result)) {
echo $row["name"] . "<br>";
}
?>
http://php.net/manual/en/function.mysqli-connect.php
http://php.net/manual/en/mysqli.construct.php
No hay comentarios:
Publicar un comentario