Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Problem z wypisaniem zmiennej
pdg1264
post
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 1
Dołączył: 17.05.2014

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


Mam problem z wypisaniem zmiennej

Chcę wyświetlić to
  1. $tresc = mysqli_real_escape_string($con, $_GET['tresc']);


Tutaj
  1. echo"<td><textarea name='tresc' cols='30' rows='20'>".$tresc."</textarea></td>";


próbowałem tak

  1. $_POST["tresc"]
  2. $tresc



cały kod
  1. <?php
  2. $con=mysqli_connect("localhost","root","pass","strona");
  3. // sprawdz polaczenie
  4. if (mysqli_connect_errno()) {
  5. echo "Błąd podczas łączenia z bazą danych: " . mysqli_connect_error();
  6. }
  7. $result = mysqli_query($con,"SELECT * FROM newsy");
  8.  
  9. $tytul = mysqli_real_escape_string($con, $_GET['tytul']);
  10. $tytulglowna = mysqli_real_escape_string($con, $_GET['tytulglowna']);
  11. $tresc = mysqli_real_escape_string($con, $_GET['tresc']);
  12.  
  13. echo"<table>";
  14. echo"<form action='update.php' method='post'>";
  15. echo"<tr>";
  16. echo"<td><p><h3>Edycja Newsa</h3></p><hr></td>";
  17. echo"</tr>";
  18. echo"<tr>";
  19. echo"<td>Tytuł</td>";
  20. echo"<td><input type='text' name='tytul' size='25' maxlength='32'/></td>";
  21. echo"</tr>";
  22. echo"<tr>";
  23. echo"<td>Tytuł na stronę głowną</td>";
  24. echo"<td><input type='text' name='tytulglowna' size='25' maxlength='20' value=''/></td>";
  25. echo"</tr>";
  26. echo"<tr>";
  27. echo"<td>Treść</td>";
  28. echo"<td><textarea name='tresc' cols='30' rows='20'>".$tresc."</textarea></td>";
  29. echo"</tr>";
  30. echo"<tr>";
  31. echo"<td><input type='submit'/></td>";
  32. echo"</tr>";
  33. echo"</form>";
  34. echo"</table>";
  35. echo"</div>";
  36.  
  37. mysqli_close($con);


Ten post edytował pdg1264 12.10.2014, 17:33:02
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
pdg1264
post
Post #2





Grupa: Zarejestrowani
Postów: 41
Pomógł: 1
Dołączył: 17.05.2014

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



Update.php
  1. <?php
  2. $con=mysqli_connect("localhost","root","pass","strona");
  3. // Check connection
  4. if (mysqli_connect_errno()) {
  5. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  6. }
  7.  
  8. // escape variables for security
  9. $tytul = mysqli_real_escape_string($con, $_POST['tytul']);
  10. $tytulglowna = mysqli_real_escape_string($con, $_POST['tytulglowna']);
  11. $tresc = mysqli_real_escape_string($con, $_POST['tresc']);
  12.  
  13. $sql="UPDATE newsy (tytul, tytulglowna, tresc)
  14. VALUES ('$tytul', '$tytulglowna', '$tresc')";
  15.  
  16. if (!mysqli_query($con,$sql)) {
  17. die('Error: ' . mysqli_error($con));
  18. }
  19.  
  20. mysqli_close($con);
  21. ?>
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: 2.10.2025 - 17:12