Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2002
    Messaggi
    51

    PHP che richiama post di WordPress

    Salve,
    ho cercato per tutto il forum e non ne sono venuto a capo anche con tutti gli accorgimenti:

    Ho un pagina PHP che richiama dei post su un DB di Wordpress, ma quando vengono visualizzati compaiono i soliti punti interrogativi (?) sui caratteri accentati, apici etc...

    Potete vedere la pagina qui http://www.maisonduchocolat.it/wp.php

    Ho provato tutti gli accorgimenti trovati qui e su altri siti ma niente da fare, vi posto il codice:

    codice:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" value="text/html; charset=utf-8" />
    <title>Documento senza titolo</title>
    </head>
    
    <body>
    <?php
    
    function mese($m) {
    	
    switch($m) {
    case 1:
    $mese = 'Gennaio';
    break;
    case 2:
    $mese = 'Febbraio';
    break;
    case 3:
    $mese = 'Marzo';
    break;
    case 4:
    $mese = 'Aprile';
    break;
    case 5:
    $mese = 'Maggio';
    break;
    case 6:
    $mese = 'Giugno';
    break;
    case 7:
    $mese = 'Luglio';
    break;
    case 8:
    $mese = 'Agosto';
    break;
    case 9:
    $mese = 'Settembre';
    break;
    case 10:
    $mese = 'Ottobre';
    break;
    case 11:
    $mese = 'Novembre';
    break;
    case 12:
    $mese = 'Dicembre';
    break;
    }
    
    return $mese;
    
    }
    
    
    // parametri per la connessione al database 
      $nomehost = "*******";      
      $nomeuser = "*******";
      $password = "*******";  
    	$nomedb = "*******";
      
    	// funzione per la connessione a MySQL 
    if($connessione = mysql_connect($nomehost,$nomeuser,$password) or die (mysql_error())) { 
    
    	// selezione del database 
    	$selezione = mysql_select_db($nomedb,$connessione) or die (mysql_error());
    	mysql_query("set names 'utf-8'");  
     	$sql = mysql_query("SELECT p.post_date p.post_content, p.post_title, p.guid FROM wp_posts AS p, wp_term_relationships AS r WHERE p.ID = r.OBJECT_ID AND r.term_taxonomy_id = '1' ORDER BY post_date DESC LIMIT 0, 1") or die (mysql_error()); 
     	
    	if(mysql_num_rows($sql) > 0){ 
      	// estrazione dei record tramite ciclo 
      	while($obj = mysql_fetch_object($sql)){ 
        	$B = stripslashes($obj->post_date); 
    			$timestamp = strtotime($B);
    				//echo "timestamp: ". $timestamp . "
    ";
    			$date = getDate($timestamp); 
    			$mday = $date['mday']; 
    			$month = mese($date['mon']); 
    			$year = $date['year']; 
        	
        	$ID = stripslashes($obj->ID); 
        	$post_title = stripslashes($obj->post_title);
        	$stringa = stripslashes($obj->post_content); 
    		$stringa = htmlspecialchars($stringa);
        	
          echo "<div>" . $mday . " " . $month . " " . $year . "
    " . $post_title . "
    ";
          
    			if (strlen($stringa)>225) {
    				$stringa_tagliata = substr($stringa,0,225); 
    				$last_space = strrpos($stringa_tagliata," ");
    				$stringa_ok = substr($stringa_tagliata, 0, $last_space+1);
    				$TagliaStringa = $stringa_ok . "...";
    			} else {
    				$TagliaStringa = $stringa;
    			}
    			echo $TagliaStringa . "</div>";
    			            
      	}  
    	} 
     
     	mysql_close();
     	
    } 
    ?>
    </body>
    </html>

  2. #2
    Utente di HTML.it L'avatar di las
    Registrato dal
    Apr 2002
    Messaggi
    1,221
    nella configurazione di Apache devi avere

    AddDefaultCharset ISO-8859-1

    se non c'è mettilo e riavvia il server

    Il calcolatore è straordinariamente veloce, accurato e stupido.
    L'uomo è incredibilmente lento, impreciso e creativo.
    L'insieme dei due costituisce una forza incalcolabile.
    (Albert Einstein)

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2002
    Messaggi
    51
    Provo e vediamo se si risolve il problema!

  4. #4
    Utente di HTML.it
    Registrato dal
    Mar 2002
    Messaggi
    51
    Purtroppo non posso modificare nulla sul server, perchè non è mio ma di un mio cliente.
    Cosa posso fare allora?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.