Errore lista presenti
Errore lista presenti postato il 13/03/2014 23:25:55 nel forum programmazione, open source e hosting
Buonasera a tutti,
io non riesco a capire cos'è che non va nel codice che vi posto qui in seguito (scusate se è lungo).
L'errore che mi restituisce è:
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in /home/sgcod428/public_html/mappaPrometheus.php on line 491
(dove la riga 491 è quella che nel codice ho scritto in grassetto).
Oltre all'errore, non aggiorna nemmeno la tabella Presenti in DB... qualcuno riesce a capire cosa voglia il mio PC da me? XD
Grazie a tutti in anticipo ^_^
<?
$MySql = "SELECT * FROM Presenti WHERE Nome = '".addslashes($_SESSION['Login'])."'";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
$IDGilda_Presenti = 0 + $rs['IDGilda'];
$rs->close;
mysql_free_result($Result);
$MySql = "SELECT * FROM Personaggio WHERE Nome = '".addslashes($_SESSION['Login'])."'";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
$Updated = 0;
if (mysql_num_rows($Result) > 0) {
$IDRazza = 0 + $rs['IDRazza'];
$IDGilda = 0 + $rs['IDGilda'];
$Master = 0 + $rs['Master'];
$Sesso = strtolower($rs["Sesso"]."");
$_SESSION['Sesso_S'] = $Sesso;
$_SESSION['Super_S'] = $rs['Super'];
$Pres = 'S';
$rs->close;
if (($IDGilda != $_SESSION['IDGilda_S']) || ($IDRazza != $_SESSION['IDRazza_S']) || ($IDGilda_Presenti == 0)){
$Updated = 1;
$MySql = "SELECT * FROM Razza WHERE IDRazza = '$IDRazza'";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
$ImgRazza = $rs['URLImg'];
$DescRazza = $rs['Razza'];
$rs->close;
$MySql = "SELECT * FROM Gilda WHERE IDGilda = '$IDGilda'";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
$ImgGilda = $rs['URLImg'];
$DescGilda = $rs['Gilda'];
$_SESSION['Esilio_S'] = $rs['Esilio'];
$_SESSION['Prigione_S'] = $rs['Prigione'];
$_SESSION['LogFinanza_S'] = $rs['LogFinanza'];
$_SESSION['LogDoppi_S'] = $rs['LogDoppi'];
$_SESSION['Gst_AR_S'] = $rs['Gst_AR'];
$_SESSION['Gst_Razza_S'] = $rs['Gst_Razza'];
$rs->close;
mysql_free_result($Result);
$_SESSION['IDGilda_S'] = $IDGilda;
$_SESSION['ImgGilda_S'] = $ImgGilda;
$_SESSION['DescGilda_S'] = $DescGilda;
$_SESSION['IDRazza_S'] = $IDRazza;
$_SESSION['ImgRazza_S'] = $ImgRazza;
$_SESSION['DescRazza_S'] = $DescRazza;
$MySql = 'UPDATE Presenti';
$MySql.= ' SET Sesso = ''.addslashes($Sesso).''';
$MySql.= ', SET IDGilda = '.$IDGilda;
$MySql.= ', SET ImgGilda = ''.addslashes($ImgGilda).''';
$MySql.= ', SET DescGilda = ''.addslashes($DescGilda).''';
$MySql.= ', SET IDRazza = '.$IDRazza;
$MySql.= ', SET ImgRazza = ''.addslashes($ImgRazza).''';
$MySql.= ', SET DescRazza = ''.addslashes($DescRazza).''';
$MySql.= ' WHERE Nome = ''.addslashes($_SESSION['Login']).''';
mysql_query($MySql);
}
} else {
$rs->close;
mysql_free_result($Result);
exit();
}?>
<? if($_SESSION['A8']==1){?>
<div class="sidebarmenu2prom">
<? } else if($_SESSION['A8']==2){?>
<div class="sidebarmenu2prom">
<? } else {?>
<div class="sidebarmenu2prom">
<? } ?>
<table width="138" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left" valign="top">
<? if($_SESSION['A8']==1){?>
<div class="centergrossUSAF"><font color="white"><center>Entrati:</center></font></div>
<? } else if($_SESSION['A8']==2){?>
<div class="centergrossUSMC"><font color="white"><center>Entrati:</center></font></div>
<? } else {?>
<div class="centergross"><font color="white">Entrati:</font></div>
<? } ?>
<?
$st = 0 + $Stanza;
$stApparente = $st;
$MySql = "SELECT StanzaApparente FROM Mappa WHERE ID = $st";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
If ($rs) {
$stApparente = $rs["StanzaApparente"];
}
$rs->close;
mysql_free_result($Result);
$MySql = "SELECT Nome FROM Mappa_Click WHERE IDClick = '".$_SESSION['Mappa']."'";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
$NomeMappaClick=$rs['Nome'];
$rs->close;
mysql_free_result($Result);
if(($_SESSION['Admin_S']==1) || ($_SESSION['Super_S']==1) || ($_SESSION['Master']==1)){$PresentiMaster=1;}
$MySql = "SELECT * FROM Presenti WHERE Nome = '".pars($Login)."'";
$Result = mysql_query($MySql);
if (mysql_num_rows($Result)==0) {
mysql_free_result($Result);
$MySql = "INSERT INTO Presenti (Nome, Stanza, StanzaApparente, Mappa, Sesso, IDRazza, ImgRazza, IDGilda, ImgGilda, Sesso, OraEntrata, OraUscita, UltimoRefresh, Master)";
$MySql .= " VALUES ('".pars($Login)."', $st, $stApparente, '".addslashes($NomeMappaClick)."', '".$_SESSION['IDRazza_S']."', '".$_SESSION['ImgRazza_S']."', '".$_SESSION['IDGilda_S']."', '".$_SESSION['ImgGilda_S']."', '".$_SESSION['Sesso_S']."', NOW(), '2037-12-31 00:00:00', NOW(),".$PresentiMaster." )";
$Result = mysql_query($MySql);
mysql_free_result($Result);
} else {
mysql_free_result($Result);
if ($Updated == 1) {
$MySql = "UPDATE Presenti SET Stanza = $st, StanzaApparente = $stApparente, Mappa = '".addslashes($NomeMappaClick)."', UltimoRefresh = NOW(), OraUscita = '2037-12-31 00:00:00', Sesso='".$_SESSION['Sesso_S']."', IDRazza='".$_SESSION['IDRazza_S']."', ImgRazza = '".$_SESSION['ImgRazza_S']."', IDGilda='".$_SESSION['IDGilda_S']."', ImgGilda='".$_SESSION['ImgGilda_S']."' WHERE Nome = '".pars($Login)."'";
$Result = mysql_query($MySql);
} else {
$MySql = "UPDATE Presenti SET Stanza = $st, StanzaApparente = $stApparente, Mappa = '".addslashes($NomeMappaClick)."', UltimoRefresh = NOW(), OraUscita = '2037-12-31 00:00:00' WHERE Nome = '".pars($Login)."'";
$Result = mysql_query($MySql);
}
};
$MySql="Select * From Presenti WHERE DATE_ADD(OraEntrata, INTERVAL 4 MINUTE) > NOW() ORDER BY Nome";
$Result = mysql_query($MySql);
while($rs = mysql_fetch_array($Result))
{
if($_SESSION['A8']==1){?>
<? echo "<a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0> <font color="#FFFFFF">".htmlspecialchars(trim($rs["Nome"]))."</font></a><br>"; ?>
<? } else if($_SESSION['A8']==2){?>
<? echo "<a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0> <font color="#FFFFFF">".htmlspecialchars(trim($rs["Nome"]))."</font></a><br>"; ?>
<? } else {
echo "<a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0> ".htmlspecialchars(trim($rs["Nome"]))."</a><br>";
}
}
$rs->close;
mysql_free_result($Result);
?>
</td>
<td align="left" valign="top">
<div class="centergross"><font color="white">Usciti:</font></div>
<?
$MySql="Select * From Presenti WHERE (OraUscita < NOW()) AND (DATE_ADD(OraUscita, INTERVAL 3 MINUTE) > NOW()) ORDER BY Nome";
$Result = mysql_query($MySql);
while($rs = mysql_fetch_array($Result))
{
if($_SESSION['A8']==1){?>
<? echo "<a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0> <font color="#FFFFFF">".htmlspecialchars(trim($rs["Nome"]))."</font></a><br>"; ?>
<? } else if($_SESSION['A8']==2){?>
<? echo "<a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0> <font color="#FFFFFF">".htmlspecialchars(trim($rs["Nome"]))."</font></a><br>"; ?>
<? } else {
echo "<a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0> ".htmlspecialchars(trim($rs["Nome"]))."</a><br>";
}
}
$rs->close;
mysql_free_result($Result);
if ($Stanza > 0)
{
?>
</td></tr>
</table>
</div>
<? if($_SESSION['A8']==1){?>
<div class="sidebarmenu2prom">
<? } else if($_SESSION['A8']==2){?>
<div class="sidebarmenu2prom">
<? } else {?>
<div class="sidebarmenu2prom">
<? } ?>
<div class="centergross"><? echo $Breve ?>:</div><br>
<?
$MySql="Select * From Presenti where OraUscita = '2037-12-31 00:00:00' and Stanza = $Stanza AND Is_Invisibile = 0 ORDER BY Nome LIMIT 0,12";
$Result = mysql_query($MySql) or die(mysql_error());
while($rs = mysql_fetch_array($Result))
{
if($_SESSION['A8']==1){?>
<? echo " <font color="#FFFFFF"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0 title='Sussurro privato' onclick="Javascript:parent.palestra.chatinput.document.invio.Messaggio.value='@".$rs["Nome"]."@';parent.palestra.chatinput.document.invio.Messaggio.focus()" target=palestra> <a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"><font color="#FFFFFF">" .htmlspecialchars(trim($rs["Nome"]))." </font> </a><br> </font>"; ?>
<? } else if($_SESSION['A8']==2){?>
<? echo " <center><font color="#FFFFFF"> <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0 title='Sussurro privato' onclick="Javascript:parent.palestra.chatinput.document.invio.Messaggio.value='@".$rs["Nome"]."@';parent.palestra.chatinput.document.invio.Messaggio.focus()" target=palestra> <a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)"><font color="#FFFFFF">" .htmlspecialchars(trim($rs["Nome"]))." </font> </a><br> </font></center>"; ?>
<? } else {
echo " <IMG SRC='img/testamini".strtolower($rs["Sesso"]).".gif' width=8 height=8 border=0 title='Sussurro privato' onclick="Javascript:parent.palestra.chatinput.document.invio.Messaggio.value='@".$rs["Nome"]."@';parent.palestra.chatinput.document.invio.Messaggio.focus()" target=palestra> <a href=""onClick="window.open('NS.php?pg=".urlencode(trim($rs["Nome"]))."','ext1','toolbar=0, location=0, directories=0, statusbar=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=440, height=685');return(false)">".htmlspecialchars(trim($rs["Nome"]))."</a><br>";
}
}
$rs->close;
mysql_free_result($Result);
}
$cont=0;
$MySql="SELECT count(Nome) AS Numero FROM Presenti WHERE OraUscita = '2037-12-31 00:00:00' AND Is_Invisibile = '0'";
$Result = mysql_query($MySql);
$rs = mysql_fetch_array($Result);
$cont=$rs["Numero"];
$rs->close;
mysql_free_result($Result);
?>
Pagine → 1
13/03/2014 23:46:25 e modificato da dyrr il 13/03/2014 23:47:16
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
fonte: http://php.net/manual/en/function.mysql-query.php#refsect1-function.mysql-query-returnvalues ↗
If a non-resource is used for the result, an error of level E_WARNING will be emitted. It's worth noting that mysql_query() only returns a resource for SELECT, SHOW, EXPLAIN, and DESCRIBE queries.
fonte: http://www.php.net/manual/en/function.mysql-free-result.php ↗
Tu cerchi di fare un mysql_free_result() su una quesry di insert che non da come ritorno una resporce ma un valore true o false per cui come spiegato dalla funzione genera un warning.
in casi di insert e update invece di un
$Result = mysql_query($MySql);
puoi fare direttamente:
mysql_query($MySql);
quanto al fatto che non ti aggiorna la tabella hai provato a stampare a video con un echo $MySql la query e inserirla nel phpmyadmin per vedere se ti genera qualche errore o cosa?
14/03/2014 11:51:17
Ahhhhhhhhhhhhhh <urla>
Grazie dyrr!
Si vede che ero proprio arrivato al dolce ieri sera!
È esattamente come dicevi, ora ho risolto l'errore che stampava. Per i presenti invece avevo dimenticato un pezzo di query nel file di inserimento del PG che entra nella lista presenti :-)
Grazie ^^
Discussione seguita da
Pagine → 1
Rispondi alla Discussione Segui Discussione Inoltra Discussione Forum Programmazione, Open Source e Hosting Elenco Forum
Articoli, Interviste e altre Risorse!
The Coven ↗
Imperion ↗