Skocz do zawartości

[PHP][MySQL] Błąd


Perykles

Polecane posty

Witam,

Wklejam krótki kod:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>fjdjsfoidfs</title>
</head>
<body>
<?php
    $baza = mysql_connect('host', 'root', 'haslo') or die ("Nie moglem sie polaczyc z serwerem");
mysql_select_db('baza') or die ("Nie moglem znalesc bazy danych");
    $zapytanie = "select * from tabela";
    $wynik = mysqli_query($baza, $zaytanie);
    $ile_znalezionych = mysqli_num_rows($wynik);
?>
</body>
</html>

 

Wyskakują dwa błędy:

 

Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in /home/aaa/public_html/index.php on line 12

Free Web Hosting

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/aaa/public_html/index.php on line 13

 

Co jest źle? Pomożecie?

 

Pozdrawiam,

Perykles

Link do komentarza
Udostępnij na innych stronach

Przykład z php.net:

 

<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

if ($result = mysqli_query($link, "SELECT Code, Name FROM Country ORDER BY Name")) {

   /* determine number of rows result set */
   $row_cnt = mysqli_num_rows($result);

printf("Result set has %d rows.\n", $row_cnt);

   /* close result set */
   mysqli_free_result($result);
}

/* close connection */
mysqli_close($link);
?>

Link do komentarza
Udostępnij na innych stronach

Dzięki. Poprawiłem i działa już. Mam jeszcze jendo pytanie. Może trochę nie do tego tematu, ale nie chce tworzyc tu kolejnego tematu pod rzad :P Mam hosting na 000webhost. Problem w tym, że nie pokazuje obrazków na stronie. Wszystko jest w jednym folderze, więc powinno być w porządku. Wkleje kod może:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta name="keywords" content="algorytmy, algorytmika" />
<title>Strona główna - algorytmika</title>
</head>
<body>
<img src="tlo.jpeg" alt="obrazek" />
<div id="pasek">
<table>
<tr>
<td><a href="index.html"><img src="Main.jpeg" alt="obrazek" /></a></td>
</tr>
<tr>
<td><a href="index.html"><img src="plik.jpeg" alt="obrazek" /></a></td>
</tr>
<tr>
<td><a href="index.html"><img src="Algorytmys.jpeg" alt="obrazek" /></a></td>
</tr>
<tr>
<td><a href="index.html"><img src="kryptografia.jpeg" alt="obrazek" /></a></td>
</tr>
<tr>
<td><a href="index.html"><img src="Kalkulatory.jpeg" alt="obrazek" /></a></td>
</tr>
<tr>
<td><a href="index.html"><img src="Szukaj.jpeg" alt="obrazek" /></a></td>
</tr>
<tr>
<td><a href="index.html"><img src="Download.jpeg" alt="obrazek" /></a></td>
</tr>
</table>
</div>
<div id="tresc">
Witaj wędrowsze na witrynie o algorytmice...
</div>
</body>
</html>

 

Na razie to strona napisana na szybko, żeby zobaczyc czy działa. Dlaczego nie pokazuje obrazków?

Link do komentarza
Udostępnij na innych stronach

Zarchiwizowany

Ten temat jest archiwizowany i nie można dodawać nowych odpowiedzi.

×
×
  • Utwórz nowe...