Problemi php 5

di il
2 risposte

Problemi php 5

Ciao a tutti,
Ho un problema con una pagina php (in realtà con tre pagine php).
Tempo addietro un ragazzo mi ha sviluppato per la mia associazione alcune pagine che utilizziamo durante l'evento per gestire le vendite delle fotografie.
Ieri sera ho voluto provare le pagine per verificare che tutto funzionasse ma ho avuto l'amara sorpresa che non funziona più nulla.
Io uso xampp e da quello che ho letto in rete il problema è che alcune istruzioni php versione 5 non vengono più riconosciute da php 7.
Allego le pagine di cui ho l'errore se qualcuno fosse così gentile da modificarmele lo ringrazio da subito.

Pagina Scattati

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db('db_babbo');
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo "<BODY style=\"background-color: red;\">";
echo "<div style=\"position: absolute;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 600px;height: 300px;background-color: white;\">";
echo "<center>";
echo "<h1>FOTO SCATTATE</h1>";
if(isset($_POST['inc']))
{
if($_POST["inc"]=='1')
{
//Estraggo il valore dei biglietti venduti per incrementarlo
$sql_s = 'SELECT scattati FROM biglietti WHERE ID=1';
$result=mysql_query($sql_s);
$scattato=mysql_result($result,0);
$scattato = $scattato+1;

//Aggiorno la tabella con il valore nuovo
$sql_u = "UPDATE biglietti SET scattati='$scattato' WHERE ID=1";
$retval = mysql_query( $sql_u, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "<h3 style=\"color:red;\">Foto scattata!</h3>";
}
else if($_POST["inc"]=='0')
{
//Azzero i biglietti venduti
$sql_u = "UPDATE biglietti SET scattati=0 WHERE ID=1";
$retval = mysql_query( $sql_u, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "<h3 style=\"color:red;\">Foto scattate azzerate!</h3>";
}
}
//Stampo il numero di biglietti venduti e scattati
$sql_s = 'SELECT venduti, scattati FROM biglietti WHERE ID=1';
$result = mysql_query($sql_s);
$row = mysql_fetch_row($result);
echo "<h2>" . mysql_result($result,0,'venduti') . " biglietti venduti.</h2><h2>" . mysql_result($result,0,'scattati') . " foto scattate.</h2>";

mysql_close($conn);

$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");
?>
<HTML>
<table>
<tr>
<td>
<form action="scattati.php" method="POST">
<input type="hidden" name="inc" value="1">
<input type="submit" value="INCREMENTA" style="width: 150px;height: 70px;">
</form>
</td>
<td>
<form action="scattati.php" method="POST">
<input type="hidden" name="inc" value="0">
<a onclick="return confirm('Sei sicuro?')"><input type="submit" value="AZZERA" style="width: 150px;height: 70px;"></a>
</form>
</td>
<td>
<form action="scattati.php" method="POST">
<input type="submit" value="AGGIORNA" style="width: 150px;height: 70px;">
</form>
</td>
</tr>
</table>
</center>
</div>
</HTML>

Pagina Venduti

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db('db_babbo');
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo "<BODY style=\"background-color: red;\">";
echo "<div style=\"position: absolute;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 600px;height: 300px;background-color: white;\">";
echo "<center>";
echo "<h1>BIGLIETTI VENDUTI</h1>";
if(isset($_POST['inc']))
{
if($_POST["inc"]=='1')
{
//Estraggo il valore dei biglietti venduti per incrementarlo
$sql_s = 'SELECT venduti FROM biglietti WHERE ID=1';
$result=mysql_query($sql_s);
$venduto=mysql_result($result,0);
$venduto = $venduto+1;

//Aggiorno la tabella con il valore nuovo
$sql_u = "UPDATE biglietti SET venduti='$venduto' WHERE ID=1";
$retval = mysql_query( $sql_u, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "<h3 style=\"color:red;\">Biglietto inserito!</h3>";
}
else if($_POST["inc"]=='0')
{
//Azzero i biglietti venduti
$sql_u = "UPDATE biglietti SET venduti=0 WHERE ID=1";
$retval = mysql_query( $sql_u, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "<h3 style=\"color:red;\">Biglietti venduti azzerati!</h3>";
}
}
//Stampo il numero di biglietti venduti e scattati
$sql_s = 'SELECT venduti, scattati FROM biglietti WHERE ID=1';
$result = mysql_query($sql_s);
$row = mysql_fetch_row($result);
echo "<h2>" . mysql_result($result,0,'venduti') . " biglietti venduti.</h2><h2>" . mysql_result($result,0,'scattati') . " foto scattate.</h2>";

mysql_close($conn);

$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");
?>
<HTML>
<table>
<tr>
<td>
<form action="venduti.php" method="POST">
<input type="hidden" name="inc" value="1">
<input type="submit" value="INCREMENTA" style="width: 150px;height: 70px;">
</form>
</td>
<td>
<form action="venduti.php" method="POST">
<input type="hidden" name="inc" value="0">
<a onclick="return confirm('Sei sicuro?')"><input type="submit" value="AZZERA" style="width: 150px;height: 70px;"></a>
</form>
</td>
<td>
<form action="venduti.php" method="POST">
<input type="submit" value="AGGIORNA" style="width: 150px;height: 70px;">
</form>
</td>
</tr>
</table>
</center>
</div>
</body>
</HTML>

Pagina Visulizza

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db('db_babbo');
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo "<BODY style=\"background-color: red;\">";
echo "<div style=\"position: absolute;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 600px;height: 300px;background-color: white;\">";
echo "<center>";
echo "<h1>BIGLIETTI VENDUTI</h1>";
if(isset($_POST['inc']))
{
if($_POST["inc"]=='1')
{
//Estraggo il valore dei biglietti venduti per incrementarlo
$sql_s = 'SELECT venduti FROM biglietti WHERE ID=1';
$result=mysql_query($sql_s);
$venduto=mysql_result($result,0);
$venduto = $venduto+1;

//Aggiorno la tabella con il valore nuovo
$sql_u = "UPDATE biglietti SET venduti='$venduto' WHERE ID=1";
$retval = mysql_query( $sql_u, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "<h3 style=\"color:red;\">Biglietto inserito!</h3>";
}
else if($_POST["inc"]=='0')
{
//Azzero i biglietti venduti
$sql_u = "UPDATE biglietti SET venduti=0 WHERE ID=1";
$retval = mysql_query( $sql_u, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "<h3 style=\"color:red;\">Biglietti venduti azzerati!</h3>";
}
}
//Stampo il numero di biglietti venduti e scattati
$sql_s = 'SELECT venduti, scattati FROM biglietti WHERE ID=1';
$result = mysql_query($sql_s);
$row = mysql_fetch_row($result);
echo "<h2>" . mysql_result($result,0,'venduti') . " biglietti venduti.</h2><h2>" . mysql_result($result,0,'scattati') . " foto scattate.</h2>";

mysql_close($conn);

$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");
?>
<HTML>
<table>
<tr>
<td>
<form action="venduti.php" method="POST">
<input type="hidden" name="inc" value="1">
<input type="submit" value="INCREMENTA" style="width: 150px;height: 70px;">
</form>
</td>
<td>
<form action="venduti.php" method="POST">
<input type="hidden" name="inc" value="0">
<a onclick="return confirm('Sei sicuro?')"><input type="submit" value="AZZERA" style="width: 150px;height: 70px;"></a>
</form>
</td>
<td>
<form action="venduti.php" method="POST">
<input type="submit" value="AGGIORNA" style="width: 150px;height: 70px;">
</form>
</td>
</tr>
</table>
</center>
</div>
</body>
</HTML>

Grazie mille Simone

2 Risposte

  • Re: Problemi php 5

    Fai un backup dei tuoi file e del database, usa l'estensione mysqli disponibile da php 5.0 in poi.
    Lo stile procedurale di mysqli_query usa $link (la connessione al database, mysqli_connect la tua variabile é $conn con la vecchia funzione mysql_connect) come primo argomento https://www.php.net/manual/en/mysqli.query.ph
  • Re: Problemi php 5

    simonegr ha scritto:


    Ciao a tutti,
    Ho un problema con una pagina php (in realtà con tre pagine php).
    Tempo addietro un ragazzo mi ha sviluppato per la mia associazione alcune pagine che utilizziamo durante l'evento per gestire le vendite delle fotografie.
    Ieri sera ho voluto provare le pagine per verificare che tutto funzionasse ma ho avuto l'amara sorpresa che non funziona più nulla.
    Io uso xampp e da quello che ho letto in rete il problema è che alcune istruzioni php versione 5 non vengono più riconosciute da php 7.
    Allego le pagine di cui ho l'errore se qualcuno fosse così gentile da modificarmele lo ringrazio da subito.
    Ciao,
    oltre a quanto ti ha detto giustamente Hormus dovresti dirci qual'e' l'errore che ti esce, in particolare nel file php errors (PHP56_errors.txt nel mio caso ) trovi la descrizione completa dell'errore.
Devi accedere o registrarti per scrivere nel forum
2 risposte