mysqli_connect

(PHP 5)

mysqli_connectAlias di mysqli::__construct()

Descrizione

Questa funzione รจ sinonimo di: mysqli::__construct()

add a note add a note

User Contributed Notes 3 notes

up
206
john at host2help dot com
2 years ago
The above by djfenix_31_94 at hotmail dot com is excellent - but

$query = "SELECT name FROM mytable" or die("Error in the consult.." . mysqli_error($link));
# execute the query.
$result = $link->query($query);

This is wrong - the or die will never be called in the above. It should read:

$query = "SELECT name FROM mytable";
# execute the query.
$result = $link->query($query) or die("Error in the consult.." . mysqli_error($link));

it took me a few plays to see that, hope it saves someone else a few minutes.
up
38
djfenix_31_94 at hotmail dot com
2 years ago
Simple connection to the database using this extension mysqli.
<?php
//conection:
$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));

//consultation:

$query = "SELECT name FROM mytable" or die("Error in the consult.." . mysqli_error($link));

//execute the query.

$result = $link->query($query);

//display information:

while($row = mysqli_fetch_array($result)) {
  echo
$row["name"] . "<br>";
}
?>

or

<?php
//conection:
$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));

//consultation:

$query = "SELECT name FROM mytable" or die("Error in the consult.." . mysqli_error($link));

//execute the query.

$result = mysqli_query($link, $query);

//display information:

while($row = mysqli_fetch_array($result)) {
  echo
$row["name"] . "<br>";
}
?>

Thanks by freddy alcarazo.
up
0
pieterjan dot goeman at gmail dot com
13 days ago
$result = mysqli_query($conn, $sql);
To Top