Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak sprawdzić czy dany rekord istnieje?
vieri_pl
post 20.08.2005, 11:20:54
Post #1





Grupa: Zarejestrowani
Postów: 406
Pomógł: 9
Dołączył: 24.07.2005
Skąd: Bydgoszcz

Ostrzeżenie: (0%)
-----


Pieszę mi błąd:

Wystąpił błąd
["select * from newsy where id = order by id DESC;"]
[You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id DESC' at line 1]
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
Wystąpił błąd
["UPDATE newsy SET czytano=czytano + 1 WHERE id = "]
[You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
--------------------------------------------------------------------------------


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/virtual/gry.zombie.nekromanta.pl/htdocs/page/wiadomosci.php on line 11
Brak wiadomości w bazie danych

Myślę że kod jest dobry i dlaczego mi wywala błąd!?exclamation.gif?exclamation.gif?!

Mam taki kodzik:

  1. <?php
  2. ////////////////////////////////////////////////////////////////
  3. //                        powered by:                         //
  4. //                   AK DESIGN TECHNOLOGY                     //
  5. //                          2005                              //
  6. /////////////////////////////////////////////////////////////////
  7. // Je&para;li link wygl&plusmn;da tak: wiadomosci.php?akcja=czytaj&id=2 to uzytkownik zostanie przeniesiony na strone na ktorej pokazuje się ca
    la tresc newsa
  8. if ($_GET['akcja'] == 'czytaj'){
  9. $result_newsy = sql("select * from newsy where id = $id order by id DESC;");
  10. $result_czytano = sql("UPDATE newsy SET czytano=czytano + 1 WHERE id = $id");
  11. if(mysql_num_rows($result_newsy) == 0) {
  12. print("Brak wiadomo&para;ci w bazie danych");//je&para;li nie ma newsów pokazuje się odpowiedni komunikat...
  13. }
  14. else {
  15.     while($row_newsy = mysql_fetch_row($result_newsy)) {
  16.     print("<table width="95%"  align="center"  border="0" cellspacing="0" cellpadding="0">
  17.   <tr>
  18.     <td bgcolor="#555555" valign="top" align="left"><strong>$row_newsy[1]</strong> :: $row_newsy[5]</td>
  19.      <tr>
  20.   <td valign="top">Dodał: $row_newsy[4]</td>
  21.   </tr>
  22.    <tr>
  23.    <td valign="top" colspan="3"<img src="grafika/separ.gif" witdh"1" height="15"></td>
  24.   </tr>
  25.   <tr>
  26.     <td valign="top" colspan="3">$row_newsy[2]</td>
  27.   </tr>
  28.    <tr>
  29.    <td valign="top" colspan="3"<img src="grafika/separ.gif" witdh"1" height="15"></td>
  30.   </tr>
  31.    <tr>
  32.    <td valign="top" colspan="3">$row_newsy[3]</td>
  33.   </tr>
  34.      <tr>
  35.       <td valign="top" colspan="3"<img src="grafika/separ.gif" witdh"1" height="15"></td>
  36.   </tr>
  37. </table><br>");
  38. }
  39. }//nie robi się nic
  40. }
  41. ?>
  42. <?
  43. if ($_GET['akcja'] == ''){// jeżeli nie było przekazanej akcji w linku(zmiennej)to wy&para;wietlaja się wszystkie newsy...
  44. $result_newsy = sql("select * from newsy order by id DESC;");
  45.  
  46. if(mysql_num_rows($result_newsy) == 0) {
  47. print("Brak wiadomo&para;ci w bazie danych");//je&para;li nie ma newsów pokazuje się odpowiedni komunikat...
  48. }
  49. else {
  50.     while($row_newsy = mysql_fetch_row($result_newsy)) {
  51.     print("<table width="95%"  align="center" border="0" cellspacing="0" cellpadding="0">
  52.   <tr>
  53.     <td valign="top" bgcolor="#555555" align="left"><strong><a href="index.php?dzial=wiadomosci&akcja=czytaj&id=$row_newsy[0]">$row_newsy[1] </a></strong>:: $row_newsy[5]</td>
  54.      <tr>
  55.   <td valign="top">Dodał: $row_newsy[4]</td>
  56.   </tr>
  57.   <tr>
  58.    <td valign="top" colspan="3"<img src="grafika/separ.gif" witdh"1" height="15"></td>
  59.   </tr>
  60.   <tr>
  61.     <td valign="top" colspan="3">$row_newsy[2]</td>
  62.   </tr>
  63.    <tr>
  64.    <td valign="top" colspan="3"<img src="grafika/separ.gif" witdh"1" height="15"></td>
  65.   </tr>
  66.   <tr>
  67.     <td valign="top"><a href="index.php?dzial=wiadomosci&akcja=czytaj&id=$row_newsy[0]">Czytaj dalej -->></a> </td>
  68.   </tr>
  69. </table><br>");
  70. }
  71. }//nie robi się nic
  72. }
  73. print("<center><a href="index.php?dzial=archiwum&co=wiadomosci">Pokaż wszystkie</a>");//je&para;li nie ma newsów pokazuje się odpowiedni komunikat...
  74. ?><br/><br/>
  75. <?
  76. $result_ile = sql("select count(*) from newsy;");// ile newsów w bazie danych...
  77. if(mysql_num_rows($result_ile) == 0) {
  78. print("Brak wiadomo&para;ci w bazie danych");//je&para;li nie ma newsów pokazuje się odpowiedni komunikat...
  79. }
  80. else {
  81.     while($row_ile = mysql_fetch_row($result_ile)) {
  82.     print("<center><strong><small>Wszystkich wiadomo&para;ci w bazie danych: $row_ile[0]</center></strong></small>");
  83. }
  84. }//nie robi się nic
  85. ?>


Ten post edytował vieri_pl 20.08.2005, 12:18:24
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 17:17