Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Php z 4.4 do 7.0
doknes
post
Post #1





Grupa: Zarejestrowani
Postów: 106
Pomógł: 0
Dołączył: 2.11.2014

Ostrzeżenie: (10%)
X----


Hej, mam pytanie, czy jak przeniosę sie z php 4.4 do 7.0 to mojej stronie grożą błędy?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
doknes
post
Post #2





Grupa: Zarejestrowani
Postów: 106
Pomógł: 0
Dołączył: 2.11.2014

Ostrzeżenie: (10%)
X----


Cytat(kapslokk @ 29.01.2016, 09:06:55 ) *
Tak to. Jest mysqli, PDO, ale mysql_ juz nie ma (IMG:style_emoticons/default/smile.gif)

Ale taki banał powinien działać?

  1. <?php
  2. $servername = "localhost";
  3. $username = "username";
  4. $password = "password";
  5. $dbname = "myDB";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $sql = "SELECT id, firstname, lastname FROM MyGuests";
  15. $result = $conn->query($sql);
  16.  
  17. if ($result->num_rows > 0) {
  18. // output data of each row
  19. while($row = $result->fetch_assoc()) {
  20. echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
  21. }
  22. } else {
  23. echo "0 results";
  24. }
  25. $conn->close();
  26. ?>


Ten post edytował doknes 29.01.2016, 09:14:13
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.10.2025 - 19:13