PHP 5.6.0beta1 released

mysqli_connect

(PHP 5)

mysqli_connectSinônimo de mysqli::__construct()

Descrição

Esta função é um apelido para: mysqli::__construct()

add a note add a note

User Contributed Notes 6 notes

up
38
john at host2help dot com
9 months 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
7
in0mad91 at gmail dot com
9 months ago
while($row = mysqli_fecth_array($result)) {
Need to be fixed to
while($row = mysqli_fetch_array($result)) {
up
7
djfenix_31_94 at hotmail dot com
9 months 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_fecth_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_fecth_array($result)) {
  echo
$row["name"] . "<br>";
}
?>

Thanks by freddy alcarazo.
up
2
Anonymous
5 months ago
To @cerny dot venda at gmail dot com

You have an error in your grammar, It's "mysqli_fetch_array" and you have "mysqli_fecth_array".
up
-2
david dot bleuse at outlook dot fr
7 months ago
in the example it is written
mysqli_fe<b>ct</b>h_array
instead of
mysqli_fe<b>tc</b>h_array
up
-15
cerny dot venda at gmail dot com
8 months ago
Hi,

I tried this new way connection and it ended as mysql error.
So I changed "mysqli_fecth_array($result)" to "...fetch..." and now its ok. Is it your mistake, typing error?

Thank you
To Top