Migrazione da PHP4 a PHP5

Trogo

Utente Attivo
11 Gen 2008
370
0
0
43
Sanremo
Spero ti sia divertito, magari con la mente fresca è più facile trovare i problemi.
Allora intanto c'è da cambiare questo:
PHP:
If ($IDMsg == '') {
        #----- nuovo messaggio! -----
        $MySql = 'INSERT INTO MessaggioAraldo (IDAraldo, IDMessaggioPadre, Tag, Titolo, Messaggio, Autore, IDGilda, Img, Corporazione, IDRazza, DataMessaggio)';
        $MySql .=" VALUES (".addslashes(pars($IDAraldo))."',";
        $MySql .=" '".addslashes(pars($IDMsgPadre))."',";
        $MySql .=" '".addslashes(pars($Tag))."',";
        $MySql .=" '".addslashes(pars($Titolo))."',";
        $MySql .=" '".addslashes(pars($Messaggio))."',";
        $MySql .=" '".addslashes(pars($Login))."',";
        $MySql .=" '".addslashes(pars($IDGilda_S))."',";
        $MySql .=" '".addslashes(pars($ImgGilda_S))."',";
        $MySql .=" '".addslashes(pars($DescGilda_S))."',";
        $MySql .=" '".addslashes(pars($IDRazza_S))."',";
        $MySql .=" NOW())";
        echo "<p>" . $MySql . "</p>";

Non c'era la parentesi dopo "VALUES". Eppoi quel testo del messaggio non mi piace proprio. La funzione pars(...) cosa fa?
 

Levian

Utente Attivo
30 Set 2008
51
0
0
Ho sistemato la parentesi dopo il Values e rimosso la funzione pars a tutto il file, perchè superflua.

PHP:
If ($IDMsg == '') {
        #----- nuovo messaggio! -----
        $MySql = 'INSERT INTO MessaggioAraldo (IDAraldo, IDMessaggioPadre, Tag, Titolo, Messaggio, Autore, IDGilda, Img, Corporazione, IDRazza, DataMessaggio)';
        $MySql .=" VALUES (".addslashes($IDAraldo)."',";
        $MySql .=" '".addslashes($IDMsgPadre)."',";
		$MySql .=" '".addslashes($Tag)."',";
        $MySql .=" '".addslashes($Titolo)."',";
        $MySql .=" '".addslashes($Messaggio)."',";
        $MySql .=" '".addslashes($Login)."',";
        $MySql .=" '".addslashes($IDGilda_S)."',";
        $MySql .=" '".addslashes($ImgGilda_S)."',";
        $MySql .=" '".addslashes($DescGilda_S)."',";
        $MySql .=" '".addslashes($IDRazza_S)."',";
        $MySql .=" NOW())";
        echo "<p>" . $MySql . "</p>";
		$Result = mysql_query($MySql);
 

Levian

Utente Attivo
30 Set 2008
51
0
0
INSERT INTO MessaggioAraldo (IDAraldo, IDMessaggioPadre, Tag, Titolo, Messaggio, Autore, IDGilda, Img, Corporazione, IDRazza, DataMessaggio) VALUES (3', '0', '[Off Game]', 'Test', 'Testo di prova. \'\"/\'\'è° Testo di Prova.', 'Hisoka', '8', 'gestore.gif', 'Genei Ryodan', '8000', NOW())

Continua a darmi lo stesso problema. Fintanto che non si usano apici come ' e/o " nessun problema. Nel momento in cui si usano il thread non viene inserito. Ma possibile che il php5 sia così rognoso? Sarò scemo io. T_T
 

Trogo

Utente Attivo
11 Gen 2008
370
0
0
43
Sanremo
Nel senso che adesso almeno questa parte funziona? Ora la query mi sembra a posto, a parte che manca un apice all'inizio:
........................................................|
.............................+------------------+
.............................|
INSERT [...] VALUES (3', '0', [...]
 
Ultima modifica:

Levian

Utente Attivo
30 Set 2008
51
0
0
Che urto di nervi, il problema era proprio quel cavolo di apice mancante. :p

E noi che ci scervellavamo pensando a che caspio potesse essere. >_<

In pratica questa parte:

PHP:
If ($IDMsg == '') { 
        #----- nuovo messaggio! ----- 
        $MySql = 'INSERT INTO MessaggioAraldo (IDAraldo, IDMessaggioPadre, Tag, Titolo, Messaggio, Autore, IDGilda, Img, Corporazione, IDRazza, DataMessaggio)'; 
        $MySql .=" VALUES (".addslashes($IDAraldo)."',"; 
        $MySql .=" '".addslashes($IDMsgPadre)."',"; 
        $MySql .=" '".addslashes($Tag)."',"; 
        $MySql .=" '".addslashes($Titolo)."',"; 
        $MySql .=" '".addslashes($Messaggio)."',"; 
        $MySql .=" '".addslashes($Login)."',"; 
        $MySql .=" '".addslashes($IDGilda_S)."',"; 
        $MySql .=" '".addslashes($ImgGilda_S)."',"; 
        $MySql .=" '".addslashes($DescGilda_S)."',"; 
        $MySql .=" '".addslashes($IDRazza_S)."',"; 
        $MySql .=" NOW())"; 
        echo "<p>" . $MySql . "</p>"; 
        $Result = mysql_query($MySql);

Bastava sistemarla così:

PHP:
If ($IDMsg == '') {
        #----- nuovo messaggio! -----
        $MySql = 'INSERT INTO MessaggioAraldo (IDAraldo, IDMessaggioPadre, Tag, Titolo, Messaggio, Autore, IDGilda, Img, Corporazione, IDRazza, DataMessaggio)';
        $MySql .=" VALUES ('".addslashes($IDAraldo)."',";
        $MySql .=" '".addslashes($IDMsgPadre)."',";
		$MySql .=" '".addslashes($Tag)."',";
        $MySql .=" '".addslashes($Titolo)."',";
        $MySql .=" '".addslashes($Messaggio)."',";
        $MySql .=" '".addslashes($Login)."',";
        $MySql .=" '".addslashes($IDGilda_S)."',";
        $MySql .=" '".addslashes($ImgGilda_S)."',";
        $MySql .=" '".addslashes($DescGilda_S)."',";
        $MySql .=" '".addslashes($IDRazza_S)."',";
        $MySql .=" NOW())";
		echo "<p>" . $MySql . "</p>"; 
#echo $MySql;
		$Result = mysql_query($MySql);

Ora funziona correttamente sia in PHP4 che in PHP5. Adesso mi dedico alla terza ed ultima pagina. Ringraziandoti come al solito per l'aiuto, senza di te non avrei potuto fare nulla. ^^
 

Trogo

Utente Attivo
11 Gen 2008
370
0
0
43
Sanremo
Alla fine tutto si risolve. Come spesso accade le soluzioni sono sotto gli occhi, ma si guarda troppo lontano...
 

Levian

Utente Attivo
30 Set 2008
51
0
0
Già. 2 scogli su 3 sono tolti di mezzo. Che liberazione psicologica. xD

Per comodità riporto qui l'ultimo file, nella speranza di individuare in tempi brevi il problema, che è simile a quello dei file precedenti: quando si invia un Messaggio Privato con apostrofi e/o apici da il "Crash del Sistema" ed il messaggio non arriva a destinazione.

PHP:
<? session_start();
include ('inc/variabile1.php');
include ('inc/variabile2.php');
include ('inc/variabile3.php');
include ('inc/variabile4.php');

if ($_GET['cancella'] != '') {
	$IDCanc = 0 + $_POST['IDCanc'];
	if ($IDCanc >0) {
	    $MySql = "INSERT INTO BakMessaggi SELECT * FROM Messaggi WHERE ID = $IDCanc AND Destinatario = '".pars($Login)."'";
	    mysql_query($MySql);
		$MySql = "DELETE FROM Messaggi WHERE ID = $IDCanc AND Destinatario = '".pars($Login)."'";
		mysql_query($MySql);
		header("Location: comunicazionel.php?p=$p&Ord=$Ord&Max=$Max", false);
	}
}
include ('inc/variabile5.php');
?>
<title>Comunity</title>
</head>
<body bgcolor="fbf4e4">
<div align="center">
  <table border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td><div align="center">
  <font face="Verdana" color="#800000"><strong><?= strtoupper(htmlspecialchars($par_MessaggiName)) ?></strong></font></div></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </table><br><br>
  <?
function formattadata($tim)
{
	return(strftime("%d/%m/%Y %H:%M", strtotime($tim)));
}

if ($_POST['Destinatario'] != '') {

	$Testo = htmlspecialchars($Testo);
	$Testo = str_replace("\n", "<br>", $Testo);

	$IDAllegato = 0 + $_POST['IDAllegato'];

	if ($IDAllegato > 0) {
			
			$MySql = "Select * From Messaggi";
			$MySql .= " Where ID = '$IDAllegato'";
			$MySql .= " AND Destinatario = '".pars($Login)."'";

			$Result = mysql_query($MySql);
			if ($rs = mysql_fetch_array($Result)) {
				$TestoAllegato = htmlspecialchars($par_MessaggiNameSing).' inoltrato da <b>'.htmlspecialchars($rs['Mittente']).'</b>';
				$TestoAllegato .=' il '.formattadata($rs['Spedito']).':<br>';
				$TestoAllegato .= addslashes($rs['Testo']);
				$TestoAllegato = str_replace('', '', $TestoAllegato);
				$TestoAllegato = str_replace('', '', $TestoAllegato);
			} else {
				$TestoAllegato = '<b>Allegato non presente.</b>';
			}
			$rs->close;
			mysql_free_result($Result);
			$Testo .= '<br><br>'.$TestoAllegato.'';
	}
	
	
	if (($_SESSION['IDGilda_S']%100 == 0) && (0 + $_SESSION['IDGilda_S'] > 0)) {
		$Dest = explode(',', $_POST['Destinatario']);
	} else {
		$Dest[0] = $_POST['Destinatario'];
	}
	for ($i = 0; $i <= count($Dest)-1; $i++) {
		$Destinatario = trim($Dest[$i]);
		$MySql = "SELECT Nome FROM Personaggio WHERE Nome = '$Destinatario'";
		$Result = mysql_query($MySql);
		$rs = mysql_fetch_array($Result);
		$Esiste = (!(!$rs));
		$rs->close;
		mysql_free_result($Result);
		$Certified = 0;
		if ($Esiste) {

			$MySql = "INSERT Into Messaggi (Mittente, Destinatario, Testo, Spedito) VALUES ('$Login', '$Destinatario', '$Testo', NOW())";
			mysql_query($MySql);

			$Certified = mysql_affected_rows();
			
			$IDCanc = 0 + $IDCanc;
			if (($IDCanc != "") && ($i==count($Dest)-1)) {
				$MySql = "INSERT INTO BakMessaggi SELECT * FROM Messaggi WHERE ID = $IDCanc AND Destinatario = '".pars($Login)."'";
				mysql_query($MySql);
				$MySql = "DELETE From Messaggi WHERE ID = $IDCanc AND Destinatario = '".pars($Login)."'";
				mysql_query($MySql);
	    	}
?>
  <table border=0 width="400">
    <? if($Certified == 1) { ?>
    <tr><td><div align="center"><?= htmlspecialchars($par_MessaggiNameSing) ?>:<br>
<?= stripslashes($Testo) ?><br><br>
<strong>Spedito Correttamente.</strong></div></td></tr>
    <? } else { ?>
    <tr><td><div align="center">Crash Del Sistema: 
          <?= strtoupper(htmlspecialchars($par_MessaggiNameSing)) ?> 
             
          <?= htmlspecialchars(stripslashes($Destinatario)) ?>
    </div></td></tr>
    <tr><td><?= strftime("%d/%m/%Y %H:%M:%S") ?>
    <div align="center"></div></td></tr>
    <tr><td><?= $Testo ?>
    <div align="center"></div></td></tr>
    <? } ?>
  </table>
  <br>
  <?		} else { ?>
  Destinatario 
  '<?= htmlspecialchars($Destinatario) ?>' 
  non presente.<br>
  <?
		}
	}
} else { ?>
</div>
<form action="comunicazioneavviatal.php" method="post">
  <table width="558" height="353" border="0" align="center">
    <tr>
      <td width="418"><div align="center">Destinatario
            <?
if (($_SESSION['IDGilda_S']%100 == 0) && (0 + $_SESSION['IDGilda_S'] > 0)) {
	echo '[Power]';
}
?><br>
            <input type="text" size="20" name="Destinatario" value="<?= $Dest ?>">
            <br><br>Comunicazione<br>
            <textarea name="Testo" rows="3" cols="35"></textarea>    
          <br>
              
      </div></td>
      <td width="130">
        <div align="left">
          <input type="submit" value="Spedisci" Style="font-weight:bold;font-family:Verdana;font-size:8pt"> 
      </div></td></tr>
      <?
if ($_POST['allega'] != '') {
	
	$MySql = "Select * From Messaggi";
	$MySql .= " Where ID = '".$_POST['IDCanc']."'";
	$MySql .= " AND Destinatario = '".pars($Login)."'";

	$Result = mysql_query($MySql);
	if($rs = mysql_fetch_array($Result)) {
	?>	<input type=hidden name=IDAllegato value="<?= $_POST['IDCanc'] ?>">
          <td><div align="center"></div></td>
          </tr> <?
	}
	$rs->close;
	mysql_free_result($Result);
}
?>
    </table>
    <? if (($_GET['cancella'] != '') || ($_GET['cancellaerispondi'] != '')) { ?>
    <input type=hidden name="IDCanc" value="<?= $_POST['IDCanc'] ?>">
    <? } ?>
    <input type=hidden name="p" value="<?= $_POST['p'] ?>">
    <input type=hidden name="Ord" value="<?= $_POST['Ord'] ?>">
    <input type=hidden name="Max" value="<?= $_POST['Max'] ?>">
  </div>
</form>
  <div align="center">
  <? } ?>
  </div>
  </div>
</body>
</html>
 
Ultima modifica:

Trogo

Utente Attivo
11 Gen 2008
370
0
0
43
Sanremo
Anche in questo pezzo direi che una addslashes potrebbe risultare utile...

PHP:
        $Certified = 0;
        if ($Esiste) {

            $MySql = "INSERT Into Messaggi (Mittente, Destinatario, Testo, Spedito) VALUES ('$Login', '$Destinatario', '".addslashes($Testo)."', NOW())";
            mysql_query($MySql);
 

Levian

Utente Attivo
30 Set 2008
51
0
0
Sì, era quello il problema. Ora va tutto a gonfie vele. Non mi sembra vero, Grazie Trogo. ^^
 
Discussioni simili
Autore Titolo Forum Risposte Data
G migrazione Joomla 3.10 a 4.x Joomla 2
J migrazione da php 5.3 a 7.0 PHP 1
bubino8 [PHP] Gestionale Migrazione DB PHP 0
P Migrazione sito da http a https per rispettare linee guida google SEO e Posizionamento 12
booklisa Migrazione da Hosting Condiviso a Cloud CMS (Content Management System) 0
M windows 7 - Errore in migrazione a windows 10 Windows e Software 1
P Problemi migrazione da Apache 2.2.9 ad Apache2 Apache 0
felino [Cerco / Retribuito] Virtuemart: migrazione da 1.x a 3 Offerte e Richieste di Lavoro e/o Collaborazione 1
G Migrazione dominio e cambiamento DNS Domini 1
T Consigli migrazione da Phpbb a VBulletin CMS (Content Management System) 0
F problema migrazione sito joomla ad altro provider - non parte configurazione Joomla 3
F migrazione commenti jcomment 1.5 alla 2.5 Joomla 0
B Creazione Forum e migrazione di quello vecchio. PHP 1
P joomla: potrei riscontrare problemi migrazione dalla versione 1x alla 1.5 Joomla 13
T Migrazione blog Hosting 0
S AIUTOOOOOOOOOOOO!!!!!!!Migrazione da ASP a PHP PHP 1
E problemi migrazione script php su vers 4.1 PHP 0
S [MsSQL > MySQL] Migrazione struttura e dati e' possibile? MySQL 0
Z Migrazione da MySQL 3.23.58 a MySQL 4.0.18 Database 0
Z PHP4 e PHP5 PHP 18
L Pagina di registrazione (php4 -> php5) PHP 26
P Funzione "http_build_query" per PHP4 PHP 0
V Problema form da PHP4 a PHP5 PHP 0
L [gratuito] cerco sistema news xml in php5 Offerte e Richieste di Lavoro e/o Collaborazione 1
Monital Contare il numero di righe con php5 PHP 10
L Cerco esempio con classi php5 PHP 3
I PHP5, or not PHP5: that is the question PHP 5
M abilitare zip in php5 su linux PHP 1
H add videoplayer in php5/Mysql PHP 11
N problemi con le date in PHP5 PHP 3
M Script PHP5 PHP 0
peppoweb Php5: novità importanti PHP 0

Discussioni simili