Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Call to undefined function conn() ...?
czezz
post
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 0
Dołączył: 24.07.2003

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


Znalazłem poniższy kod w sieci.
Ma on służyć do generowania dynamicznej tabeli dopasowującej się do zapytania SQL.
Problem w tym, że przy wykonaniu pojawia mi się taki błąd: Fatal error: Call to undefined function conn() in /var/www/portal2.php on line 6
Nie wiem w czym problem ? Czy ktoś mi może podpowiedzieć ?

  1. <?php
  2. include("conn.php");
  3. //$query = "select field1, fieldn from table [where clause][group by clause][order by clause][limit clause]";
  4.  
  5. $query = "select * from kids";
  6. $result = conn($query);
  7. if (($result)||(mysql_errno == 0))
  8. {
  9. echo "<table width='100%'><tr>";
  10. if (mysql_num_rows($result)>0)
  11. {
  12. //loop thru the field names to print the correct headers
  13. $i = 0;
  14. while ($i < mysql_num_fields($result))
  15. {
  16. echo "<th>". mysql_field_name($result, $i) . "</th>";
  17. $i++;
  18. }
  19. echo "</tr>";
  20.  
  21. //display the data
  22. while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
  23. {
  24. echo "<tr>";
  25. foreach ($rows as $data)
  26. {
  27. echo "<td align='center'>". $data . "</td>";
  28. }
  29. }
  30. }else{
  31. echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>";
  32. }
  33. echo "</table>";
  34. }else{
  35. echo "Error in running query :". mysql_error();
  36. }
  37. ?>



Plik conn.php utworzyłem sam w takim formacie:
  1. <?php
  2. // Connects to Our Database
  3. mysql_connect("localhost", "root", "haslosql") or die(mysql_error());
  4. ?>

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: 24.12.2025 - 19:51