Errore con le emotions [javascript + php]

valient13

Utente Attivo
6 Apr 2012
96
0
0
Sicilia
Ho provato ad inserire nei commenti di un blog, le emotions, solo ke quando vado per farle visualizzare mi dà degli errori, se metto "<3" mi visualizza solo il record giusto, e lo visualizza cosi:
immagine.png
questo è il codice:
PHP:
<?php 
	// inclusione del file di funzione
	require_once __DIR__ . '/functions.php'; 
	// istanza della classe
	$iscrizione = new Iscrizioni();

	$colname_leggi = "1";
	if (isset($_GET['id'])) {
	  $colname_leggi = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
	}
	$query_leggi = sprintf("SELECT * FROM articoli WHERE id = %s", $colname_leggi);
	$leggi = mysql_query($query_leggi) or die(mysql_error());
	$row_leggi = mysql_fetch_assoc($leggi);
	$totalRows_leggi = mysql_num_rows($leggi);
	
	//metodo per cancellare i messaggi
	$message = mysql_query("SELECT * FROM commenti ORDER BY id DESC") or die ("Errore Query"); 
	if(isset($_POST['cancella'])){
	    // verifica
	    if(is_array($_POST['id'])){
	        foreach($_POST['id'] as $id){
	            if($id !="" && is_numeric($id)){
	                $query = "DELETE FROM commenti WHERE id=$id";
	                $ris=mysql_query($query);
	                	if($query) echo '<meta http-equiv="refresh" content="0;url=index.php"> ';
	            }
	        }
	    }
	}
	
	require_once __DIR__ . '/header.php'; 
?>
	<!-- Emotions -->
	<link href='http://fonts.googleapis.com/css?family=Raleway:100' rel='stylesheet' type='text/css'>
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/jquery.emotions.js"></script>
<script type="text/javascript" src="js/jquery.emotions.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#showHere").emotions();
});
</script>
	
  <!-- Content -->
  <div id="content">
  	<div id="conteiner">
	 <div id="post_title">
  	 <strong><?php echo $row_leggi['titolo']; ?></strong>
  	 </div>
  	 <div id="post_date">
  	 Scritto Da: <?php echo $row_leggi['autore']; ?><br>
  	 Scritto il: <?php echo $row_leggi['data']; ?>
  	 </div>
     <div id="post_content">
     <?php echo $row_leggi['testo']; ?>
     </div>
     <div id="post_title"><strong>Commenti</strong></div>
     	<div id="post_content">
     	<table width="100%">
	     	<?php 
	     	$comment = "SELECT id,nome,commento,data,id_articolo,id_utente FROM commenti WHERE id_articolo='$colname_leggi' ORDER BY data DESC";
    		$result = mysql_query($comment) or die(mysql_error());
			if (mysql_num_rows($result)>0) {
				while ($row = mysql_fetch_assoc($result)) {
					//metodo per recuperare l'avatar
					$avatarid = sprintf('SELECT avatar FROM iscritti WHERE id_utente = %d', $row['id_utente']);
					$avatar1 = mysql_query($avatarid) or die(mysql_error());
					if (mysql_num_rows($avatar1)==1) {
						$row3 = mysql_fetch_assoc($avatar1);
						$location1 = $row3['avatar'];
					}
					echo "<tr><td><div class=\"message\"><table width=\"100%\"><tr>
						<td width=\"15%\" align=\"center\">
							<img src=\"$location1\" width=\"60\" height=\"60\">
						</td>
						<td width=\"70%\">
							<div class=\"message_title\">{$row['nome']}</div>
							<br>
							<div id=\"showHere\">";
							echo "<3".$row['commento'];
							echo "</div>
						</td>
						<td width=\"15%\" align=\"center\" style=\"font-size: 12px;\">{$row['data']}<br>";
							if ($iscrizione->verifica_sessione()) {
								$id_utente = $_SESSION['id_utente'];
								// se il confronto genera una corrispondenza..
								if ($row['id_utente'] == $id_utente) {
								echo '
								<form name="$name_form" method="post" action='.$_SERVER['PHP_SELF'].'>
									<input name="id[]" type="hidden" id="id" value="'.$row['id'].'">
									<input type="submit" name="cancella[]"  value="Cancella">
								</form>';
							}
						}
						echo '</td>
						</tr></table></div></td></tr>';	
				} 
			}
			else {
				echo '<b>Non ci sono commenti</b>';
			}
			?>
     	</table>
     	</div>
     	
     <?php
     // chiamata al metodo per la verifica della sessione
	if (!$iscrizione->verifica_sessione())
	{
  	  	 echo '<center><b>Per commentare devi effettuare il login</b></center>';
  	  	 
  	 } else {
  		 $data=date('d/m/Y H:i'); 
         $id_utente = $_SESSION['id_utente'];
  		 $userSql = sprintf("SELECT nome_reale FROM iscritti WHERE id_utente='$id_utente'");
         $userResult = mysql_query($userSql) or die(mysql_error());
         $userRow = mysql_fetch_assoc($userResult); 
  	    echo <<< EOD
	    <div id="post_title"><strong>Invia un Commento</strong></div>
	    <div id="post_content">
	    <form name="commenti" method="POST" action="comment.php">
	    <table width="100%">
	    <tr>
	    <td><input value="{$userRow['nome_reale']}" type="hidden" name="nome" class="tb11" readonly /></td>
	    </tr>
	   	<tr>
	    <td><input value="{$id_utente}" type="hidden" name="id_utente" class="tb11" readonly /></td>
	    </tr>
	    <tr>
	    <td align="right"><b>Commento:</b></td><td><textarea name="commento" class="tb10"></textarea></td>
	    </tr>
		<tr>
		<td colspan="2"><b>Emotions:</b> " o:) ", " :3 ", " o.O ", " :'( ", " 3:) ", " :( ", " :O ", " 8) ", " :D ", " >:( ", " <3 ", " ^_^ ", " :* ", " :v ", " :) ", " -_- ", " 8| ", " :p "," :/ ", " >:O ", " ;) "</td>
		</tr>
	    <tr>
	    <td align="center" colspan="2">
	    <input name="data" type="hidden" id="data" value="{$data}" />
	    <input name="id_pagina" name="id_pagina" type="hidden" value="{$colname_leggi}" />
	    <input name="inserisci" type="submit" id="inserisci" class="tb12" value="Inserisci" />
	    </td>
	    </tr>
	    </table>
	    </form></div>
EOD;
}     


?>

  	</div>
    <?php require_once __DIR__ . '/sidebar.php'; ?>
  </div>
  
<?php
	require_once __DIR__ . '/footer.php';  
	mysql_free_result($leggi);
?>
altrimenti se levo il "<3" me lo visualizza cosi:
Immagine2.png

questo è il codice:
PHP:
<?php 
	// inclusione del file di funzione
	require_once __DIR__ . '/functions.php'; 
	// istanza della classe
	$iscrizione = new Iscrizioni();

	$colname_leggi = "1";
	if (isset($_GET['id'])) {
	  $colname_leggi = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
	}
	$query_leggi = sprintf("SELECT * FROM articoli WHERE id = %s", $colname_leggi);
	$leggi = mysql_query($query_leggi) or die(mysql_error());
	$row_leggi = mysql_fetch_assoc($leggi);
	$totalRows_leggi = mysql_num_rows($leggi);
	
	//metodo per cancellare i messaggi
	$message = mysql_query("SELECT * FROM commenti ORDER BY id DESC") or die ("Errore Query"); 
	if(isset($_POST['cancella'])){
	    // verifica
	    if(is_array($_POST['id'])){
	        foreach($_POST['id'] as $id){
	            if($id !="" && is_numeric($id)){
	                $query = "DELETE FROM commenti WHERE id=$id";
	                $ris=mysql_query($query);
	                	if($query) echo '<meta http-equiv="refresh" content="0;url=index.php"> ';
	            }
	        }
	    }
	}
	
	require_once __DIR__ . '/header.php'; 
?>
	<!-- Emotions -->
	<link href='http://fonts.googleapis.com/css?family=Raleway:100' rel='stylesheet' type='text/css'>
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/jquery.emotions.js"></script>
<script type="text/javascript" src="js/jquery.emotions.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#showHere").emotions();
});
</script>
	
  <!-- Content -->
  <div id="content">
  	<div id="conteiner">
	 <div id="post_title">
  	 <strong><?php echo $row_leggi['titolo']; ?></strong>
  	 </div>
  	 <div id="post_date">
  	 Scritto Da: <?php echo $row_leggi['autore']; ?><br>
  	 Scritto il: <?php echo $row_leggi['data']; ?>
  	 </div>
     <div id="post_content">
     <?php echo $row_leggi['testo']; ?>
     </div>
     <div id="post_title"><strong>Commenti</strong></div>
     	<div id="post_content">
     	<table width="100%">
	     	<?php 
	     	$comment = "SELECT id,nome,commento,data,id_articolo,id_utente FROM commenti WHERE id_articolo='$colname_leggi' ORDER BY data DESC";
    		$result = mysql_query($comment) or die(mysql_error());
			if (mysql_num_rows($result)>0) {
				while ($row = mysql_fetch_assoc($result)) {
					//metodo per recuperare l'avatar
					$avatarid = sprintf('SELECT avatar FROM iscritti WHERE id_utente = %d', $row['id_utente']);
					$avatar1 = mysql_query($avatarid) or die(mysql_error());
					if (mysql_num_rows($avatar1)==1) {
						$row3 = mysql_fetch_assoc($avatar1);
						$location1 = $row3['avatar'];
					}
					echo "<tr><td><div class=\"message\"><table width=\"100%\"><tr>
						<td width=\"15%\" align=\"center\">
							<img src=\"$location1\" width=\"60\" height=\"60\">
						</td>
						<td width=\"70%\">
							<div class=\"message_title\">{$row['nome']}</div>
							<br>
							<div id=\"showHere\">";
							echo $row['commento'];
							echo "</div>
						</td>
						<td width=\"15%\" align=\"center\" style=\"font-size: 12px;\">{$row['data']}<br>";
							if ($iscrizione->verifica_sessione()) {
								$id_utente = $_SESSION['id_utente'];
								// se il confronto genera una corrispondenza..
								if ($row['id_utente'] == $id_utente) {
								echo '
								<form name="$name_form" method="post" action='.$_SERVER['PHP_SELF'].'>
									<input name="id[]" type="hidden" id="id" value="'.$row['id'].'">
									<input type="submit" name="cancella[]"  value="Cancella">
								</form>';
							}
						}
						echo '</td>
						</tr></table></div></td></tr>';	
				} 
			}
			else {
				echo '<b>Non ci sono commenti</b>';
			}
			?>
     	</table>
     	</div>
     	
     <?php
     // chiamata al metodo per la verifica della sessione
	if (!$iscrizione->verifica_sessione())
	{
  	  	 echo '<center><b>Per commentare devi effettuare il login</b></center>';
  	  	 
  	 } else {
  		 $data=date('d/m/Y H:i'); 
         $id_utente = $_SESSION['id_utente'];
  		 $userSql = sprintf("SELECT nome_reale FROM iscritti WHERE id_utente='$id_utente'");
         $userResult = mysql_query($userSql) or die(mysql_error());
         $userRow = mysql_fetch_assoc($userResult); 
  	    echo <<< EOD
	    <div id="post_title"><strong>Invia un Commento</strong></div>
	    <div id="post_content">
	    <form name="commenti" method="POST" action="comment.php">
	    <table width="100%">
	    <tr>
	    <td><input value="{$userRow['nome_reale']}" type="hidden" name="nome" class="tb11" readonly /></td>
	    </tr>
	   	<tr>
	    <td><input value="{$id_utente}" type="hidden" name="id_utente" class="tb11" readonly /></td>
	    </tr>
	    <tr>
	    <td align="right"><b>Commento:</b></td><td><textarea name="commento" class="tb10"></textarea></td>
	    </tr>
		<tr>
		<td colspan="2"><b>Emotions:</b> " o:) ", " :3 ", " o.O ", " :'( ", " 3:) ", " :( ", " :O ", " 8) ", " :D ", " >:( ", " <3 ", " ^_^ ", " :* ", " :v ", " :) ", " -_- ", " 8| ", " :p "," :/ ", " >:O ", " ;) "</td>
		</tr>
	    <tr>
	    <td align="center" colspan="2">
	    <input name="data" type="hidden" id="data" value="{$data}" />
	    <input name="id_pagina" name="id_pagina" type="hidden" value="{$colname_leggi}" />
	    <input name="inserisci" type="submit" id="inserisci" class="tb12" value="Inserisci" />
	    </td>
	    </tr>
	    </table>
	    </form></div>
EOD;
}     


?>

  	</div>
    <?php require_once __DIR__ . '/sidebar.php'; ?>
  </div>
  
<?php
	require_once __DIR__ . '/footer.php';  
	mysql_free_result($leggi);
?>

jquery.emotions.js
Codice:
(function($){	
	$.fn.emotions = function(options){
		$this = $(this);
		var opts = $.extend({}, $.fn.emotions.defaults, options);
		return $this.each(function(i,obj){
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;					   	
			var x = $(obj);
			// Entites Encode 
			var encoded = [];
			for(i=0; i<o.s.length; i++){
				encoded[i] = String(o.s[i]).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
			}
			for(j=0; j<o.s.length; j++){
				var repls = x.html();
				if(repls.indexOf(o.s[j]) || repls.indexOf(encoded[j])){
					var imgr = o.a+o.b[j]+"."+o.c;			
					var rstr = "<img src='"+imgr+"' border='0' />";	
					x.html(repls.replace(o.s[j],rstr));
					x.html(repls.replace(encoded[j],rstr));
				}
			}
		});
	}	
	// Defaults
	$.fn.emotions.defaults = {
		a : "emotions-fb/",			// Emotions folder
		b : new Array("angel","colonthree","confused","cry","devil","frown","gasp","glasses","grin","grumpy","heart","kiki","kiss","pacman","smile","squint","sunglasses","tongue","unsure","upset","wink"),			// Emotions Type
		s : new Array("o:)",":3","o.O",":'(","3:)",":(",":O","8)",":D",">:(","<3","^_^",":*",":v",":)","-_-","8|",":p",":/",">:O",";)"),
		c : "gif"					// Emotions Image format
	};
})(jQuery);


// Notes
// a - icon folder
// b - emotions name array
// c - image format
// x - current selector
// d - type of selector
// o - options
 
Ultima modifica:
Discussioni simili
Autore Titolo Forum Risposte Data
Jensen Errore di sintassi con DELETE PHP 3
P errore 404 con javascript Javascript 2
R Navigare sito con cURL, mi restituisce errore PHP 0
L File CSV con app inventor da errore Sviluppo app per Android 2
I Errore 80040220 nella newsletter con paginazione Classic ASP 0
MarcoGrazia [PHP] Download di file con errore all'interno. PHP 1
Tommy03 Errore invio email con PHP PHP 1
Max 1 Errore driver con lettore di smart card Hardware 6
A [PHP] errore 404 e invio mai path pagina con link interrotto PHP 2
3_g errore con mysql insert in PDO PHP 29
M [MySql - VB6 sp6] Problema connessione db con alcuni pc (errore Lost connection to MySQL server...). MySQL 1
M [MySQL] Solito errore #1064 con poca comprensione MySQL 14
L [PHP] upload con errore PHP 2
auritidesign Errore con mysqli_fetch_array PHP 3
C [MySQL] errore nell'importazione tabella con file csv MySQL 0
6 Errore pubblicazione sito con Muse Webdesign e Grafica 0
romeocharly errore del codice html con javascript durante ottimizzazione websitex5 Javascript 7
O errore INSERT con oggeto datetime MySQL 2
napuleone phpmyadmin problemi con windows 10 errore 200 PHP 0
M errore lettura data nel mysql con funzione Where PHP 1
C Errore con classe PHP 4
1 Errore di istallazione programma vb2010 con access in allegato MS Access 8
C Form con dentro div errore validatore w3c HTML e CSS 6
R Errore di comunicazione con database Mysql PHP 5
asevenx validazione W3C con errore utf-8 HTML e CSS 3
asevenx Errore di connessione e permessi in scrittura file .xml con Aruba Windows Hosting 8
M Errore ListView con ID "android.R.id.list" Sviluppo app per Android 1
J Problema con questo errore Error was: Undefined index: title linea 9 PHP 21
Z Errore con il register PHP 2
E errore php con database mysql PHP 0
V problemi con lock tables (errore 1100) come fare? MySQL 0
A Errore con header ( Location...) PHP 4
F errore con wordpress plug in WordPress 0
F Errore configurazione APACHE con PHP Apache 1
neo996sps Errore con script per invio mail PHP 3
M errore in IE con array.style Javascript 0
E errore con internet explorer Windows e Software 2
A errore : "550 cannot stor no permission" per pubblicare il sito con expression web Webdesign e Grafica 0
A errore : "550 cannot stor no permission" per pubblicare il sito con expression web HTML e CSS 1
C Errore 678 con modem alice gate 2 plus wifi Reti LAN e Wireless 3
neo996sps Errore su connessione a DB con VB2008 express Visual Basic 1
asevenx errore con l'inserimento dei dati nel database, campi vuoti Classic ASP 1
G errore con div container HTML e CSS 1
neo996sps Errore visualizzazione sito con explorer HTML e CSS 1
asevenx errore durante l'invio di email con CDONTS Classic ASP 8
F Query con errore Database 3
wer16 errore in ie con float left HTML e CSS 2
Y strano errore con immissione nickname e password PHP 8
G problemi con l'errore 0x80040E14 Classic ASP 4
S Pagine di errore con redirect PHP 7

Discussioni simili