Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][JavaScript] Unexpected token illegal
Terrorizer
post
Post #1





Grupa: Zarejestrowani
Postów: 345
Pomógł: 3
Dołączył: 31.03.2012

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


Zrobiłem sobie na stronie skrzynkę, żeby użytkownicy mogli kontaktować się między sobą.
Niektóre wiadomości nie chcą się otwierać. Otworzyłem konsolę i po kliknięciu w taką nieaktywną wiadomość wyskakuje "Uncaught SyntaxError: Unexpected token ILLEGAL".
Czytałem, że to może być wina js, ale przyczyn może być wiele. Wiadomości nie zawierały żadnych szczególnych znaków to były testowe wiadomości w stylu "asdasd"

Mam sporo kodu, jednak wrzucę, gdyby ktoś miał ochotę na to zerknąć.
  1. <div id="messagebox">
  2. <?php
  3. $nick = mysql_fetch_array(mysql_query('SELECT nick FROM users WHERE id = "'.$_SESSION['id'].'"'));
  4. $messages = mysql_query("SELECT * FROM msg WHERE receiver = '".$nick['nick']."' ORDER BY id DESC ");
  5. while($allmessages = mysql_fetch_assoc($messages)){
  6. $x = $allmessages['id'];
  7. $m = $allmessages['message'];
  8. $nickfetch = mysql_fetch_array(mysql_query("SELECT * FROM msg WHERE receiver = '".$nick['nick']."' AND id = '".$x."' "));
  9. $n = $nickfetch['sender'];
  10. $s = $allmessages['seen'];
  11. echo "<button class='my-button' id='".$x."' onClick=\"openmsg('$m','$n');seenupdate('$x')\">";
  12. echo "<div class='left'>" . substr($allmessages['message'],0,40) . " " . "..." . "</div>";
  13. echo "<div class='right'>" . $allmessages['date'] . " " . " " . " ";
  14. echo '<div class="nicklink"><a href="user.php?user=' . $allmessages['sender'] . '">' . $allmessages['sender'] .'</div>';
  15.  
  16. echo "</button>". "<br /> <br />";
  17. if ($s == "no"){
  18. echo "<script>
  19. $(document.getElementById(".$x.")).css('background-color', '#adff2f');
  20. $(document.getElementById(".$x.")).css('color', 'black');
  21. </script>
  22. ";
  23. }
  24. }
  25. ?>
  26. </div>


  1. <script>
  2. function openmsg(m,n) {
  3. $(document).ready(function(){
  4. document.getElementById("messagebox").innerHTML = "<div class='mes'>Wiadomość:<br />" + m + "<br /><br /><a href='mailbox.php' id='wstecz'><button>wstecz</button></a>" + "<a href='respond.php?user=" + n + "' id='wstecz'><button>odpowiedz</button></a></div>";
  5. });
  6. }
  7. </script>
  8.  
  9. <script>
  10. function seenupdate(x) {
  11. $.ajax({
  12. type : "POST",
  13. url : "messageseenupdate.php",
  14. data : {
  15. seen : "YES",
  16. id : x
  17. }
  18. });
  19. }
  20. </script>


EDIT: w konsoli błąd wskazuje mi na coś takiego:
  1. <script>(function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {openmsg('wiadomość wiadomość wiadomoooość
  2. ','KrolowaJadwiga');seenupdate('98')
  3. };}}}})</script>


Ten post edytował Terrorizer 16.12.2014, 21:58:43
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 Aktualny czas: 21.08.2025 - 21:27