Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [sql] zapytanie
Raffal
post 18.07.2007, 15:43:19
Post #1





Grupa: Zarejestrowani
Postów: 111
Pomógł: 0
Dołączył: 19.06.2006

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


nie moge sobie poradzic ze zlozeniem zapytania do pobierania danych zaleznych (where) od danych zawartych w innej tabeli pobralem obydwie i zlozylem tak ale cos jest nie tak


  1. $id_koment=mysql_query('select * from komentarze order by data_koment where id_news='".$w[0]") ;




Parse error: syntax error, unexpected '"' in
?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
skowron-line
post 18.07.2007, 16:08:02
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


uzywaj bbcode
  1. <?php
  2. $id_koment=mysql_query('select * from komentarze order by data_koment where id_news="'.$w[0].") ;
  3. ?>


Ten post edytował skowron-line 18.07.2007, 16:08:45


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
Raffal
post 18.07.2007, 16:46:11
Post #3





Grupa: Zarejestrowani
Postów: 111
Pomógł: 0
Dołączył: 19.06.2006

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


ok dzieki mam jeszcze jeden problem tzn chce stworzyc sobie system newsow z komentarzami i stworzylem cos takiego

  1. <?
  2. include "php/param.php";
  3. $id=mysql_query('select * from news') ;
  4. //echo (mysql_error);
  5. while ($w=mysql_fetch_row($id)){
  6.  echo ("<P class=TRESCNAGLOWEK>");
  7.  echo $w[1];
  8.  echo ("</P>");
  9.  echo ("<P class=TRESC>");
  10.  echo ("<img src=");
  11.  echo $w[3];
  12.  echo (">"); 
  13.  echo $w[2];
  14.  echo ("<br>");
  15.  echo("<font size=1 color=gray>");
  16.  echo $w[0];
  17.  
  18.  echo (" ");
  19.  echo $w[5];
  20.  echo (" ");
  21.  
  22.  echo $w[4];
  23.  echo ("</font>"); 
  24.  
  25.  echo "<br>";
  26. }
  27. $id2=mysql_query("select * from komentarze where id_news='".$nr."'") or die (mysql_error);
  28.  
  29. while ($v=mysql_fetch_row($id2)){
  30. echo "<table border=1><tr><td>";
  31. echo $v[2];
  32. echo "</td></tr>"; 
  33. echo "<tr><td>";
  34. echo $v[3];
  35. echo "</td></tr><tr><td>";
  36. echo $v[4];
  37. echo $v[5];
  38. echo "</td></tr></table>";
  39. }
  40.  
  41.  
  42. echo '<form method="post">';
  43. echo '<input type="text" name="autor"><br>';
  44. echo '<textarea name="tresc"></textarea>';
  45.  
  46.  $m=$_POST['tresc'];
  47.  $l=$_POST['autor'];
  48.  $k=date("Y-m-d H:i");
  49.  
  50.  $pytanie2="INSERT into komentarze values('','"$nr"','".$l."','".$k."','".$m."')"; 
  51.  mysql_query($pytanie2) or die (mysql_error);
  52.  
  53. echo '</form>';
  54.  
  55.  
  56. ?>


wyskakuje mi taki blad

Parse error: syntax error, unexpected T_VARIABLE in /home/accounts_r/raffal/public_html/php/system_news/load_news.php on line 50

a w tej lini jest wstawianie wartosci do bazy wiec nie wiem dlaczego to nie dziala ;/


ta tabela wyglada tak

id komentarza, id newsa, autor, data ,tresc

Ten post edytował Raffal 18.07.2007, 16:49:00
Go to the top of the page
+Quote Post
Darti
post 18.07.2007, 16:57:35
Post #4





Grupa: Zarejestrowani
Postów: 1 076
Pomógł: 62
Dołączył: 6.03.2005
Skąd: Wroc

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


  1. <?php
  2. $pytanie2="INSERT into komentarze values('','".$nr."','".$l."','".$k."','".$m."')";
  3. ?>


--------------------
The answer is out there, Neo. It's looking for you. And it will find you, if you want it to.
SERVER_SOFTWARE : Apache/2.2.4 (Win32) PHP/5.2.1
MySQL Client API version : 5.0.27
Go to the top of the page
+Quote Post
Raffal
post 18.07.2007, 17:09:48
Post #5





Grupa: Zarejestrowani
Postów: 111
Pomógł: 0
Dołączył: 19.06.2006

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


a jezeli chcialbym zeby otwieral sie tylko jeden wskazany news to musze zamienic pierwsze zapytanie

na

  1. <?php
  2. $id=mysql_query('select * from news where id=$nr') ;
  3. ?>


tak zmienilem dodalem tylko testowo
na gorze zmiena $nr=1 i wyskoczyl mi taki blad


Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/accounts_r/raffal/public_html/php/system_news/load_news.php on line 6

Ten post edytował Raffal 18.07.2007, 17:10:59
Go to the top of the page
+Quote Post
Darti
post 18.07.2007, 20:26:16
Post #6





Grupa: Zarejestrowani
Postów: 1 076
Pomógł: 62
Dołączył: 6.03.2005
Skąd: Wroc

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


inne cudzysłowy daj ....
  1. <?php
  2. $id=mysql_query("select * from news where id=$nr") ;
  3. ?>


--------------------
The answer is out there, Neo. It's looking for you. And it will find you, if you want it to.
SERVER_SOFTWARE : Apache/2.2.4 (Win32) PHP/5.2.1
MySQL Client API version : 5.0.27
Go to the top of the page
+Quote Post

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 - 15:11