Query modifica record che non funziona più
Buongiorno a tutti,
premetto di essere un vecchio utilizzatore di php e mysql ormai non più al passo con i tempi.
Il codice che avevo creato per gestire la mia collezione di dischi non è più perfettamente funzionante con le ultime versioni php (ho l'hosting su Altervista).
Sono riuscito a modificare il codice sostituendo alcune funzioni deprecate per quanto riguarda aggiunta record, cancellazione record e ricerca ma ho problemi sulla modifica, nel senso che il record riesco a ricercarlo, entro in modifica sul record e sembra andare tutto bene ma la modifica non si salva.
Questo è il codice relativo alla modifica dei record e ringrazio tutti quanti in anticipo:
Codice PHP:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title>Modifica Record</title>
</head>
<body>
<?php
$host = 'localhost';
$user = 'legalys';
$password = '';
$db = 'my_legalys';
$confirm=$_REQUEST['confirm'];
$id=$_REQUEST['id'];
$conne = mysqli_connect($host, $user, $password, $db) or die ("impossibile connettersi al server $host");
mysqli_select_db($conne, $db) or die ("impossibile connettersi al database $db");
if (!$confirm)
{
$query = "SELECT * FROM lp WHERE id=$id";
$dbresult = mysqli_query($conne, $query);
$AffectedRows = mysqli_affected_rows($conne);
if ($AffectedRows==0)
{
print("<h3>Non esistono record con i criteri selezionati</h3>");
}
else
{
mysqli_data_seek($dbresult,0);
$row=mysqli_fetch_row($dbresult);
print("<form method="post"action="{$_SERVER['PHP_SELF']}">");
print("<table>");
foreach ($row as $k => $v)
{
$myfield = mysqli_fetch_field($dbresult,$k);
print("<tr><td>$myfield->name</td>");
print("<td><input type="text" value="" . $v . "" name="" . $myfield->name . "" size="100" maxlength="100" ></td></tr>");
}
print("<tr><td colspan="2"><input type="submit" value="Conferma Modifiche"></td></tr> ");
print("<input type="hidden" name="confirm" value="1">");
print("<h3><a href="index1.html">Torna al Menù</a></h3>");
print("</table>");
print("</form>");
mysqli_free_result($dbresult);
mysqli_close($conne);
}
}
else
{
$titolo=$_REQUEST['TITOLO'];
$artista=$_REQUEST['ARTISTA'];
$sett=$_REQUEST['SETT'];
$supp=$_REQUEST['SUPP'];
$form=$_REQUEST['FORM'];
$conf=$_REQUEST['CONF'];
$ediz=$_REQUEST['EDIZ'];
$naz=$_REQUEST['NAZ'];
$st=$_REQUEST['ST'];
$barcode=$_REQUEST['BARCODE'];
$cod=$_REQUEST['COD'];
$crisbc=$_REQUEST['CRISBC'];
$anno_ed=$_REQUEST['ANNO_ED'];
$anno=$_REQUEST['ANNO'];
$etic=$_REQUEST['ETIC'];
$brani=$_REQUEST['BRANI'];
$note=$_REQUEST['NOTE'];
$bustatesti=$_REQUEST['bustatesti'];
$prezzo=$_REQUEST['PREZZO'];
$cond=$_REQUEST['COND'];
$dett=$_REQUEST['DETT'];
$num=$_REQUEST['NUM'];
$copie=$_REQUEST['COPIE'];
$link=$_REQUEST['LINK'];
$query = "update lp set titolo="$titolo"," . " artista="$artista","
. " sett="$sett","
. " supp="$supp","
. " form="$form","
. " conf="$conf","
. " ediz="$ediz","
. " naz="$naz","
. " st="$st","
. " barcode="$barcode","
. " cod="$cod","
. " crisbc="$crisbc","
. " anno_ed="$anno_ed","
. " anno="$anno","
. " etic="$etic","
. " brani="$brani","
. " note="$note","
. " bustatesti="$bustatesti","
. " prezzo="$prezzo","
. " cond="$cond","
. " dett="$dett","
. " num="$num","
. " copie="$copie","
. " link="$link""
. "where id=$id";
$dbresult = mysqli_query($conne, $query);
$AffectedRows = mysqli_affected_rows($conne);
if ($AffectedRows!=0)
{
print("<h3>Il Record è Stato Aggiornato Con Successo</h3>");
print("<h3><a href="index1.html">Torna Al Menu</a></h3>");
print("<h3><a href="search_mob.html">Nuova Ricerca</a></h3>");
print("<h3><a href="insert.html">Inserimento Record</a></h3>");
}
mysqli_close($conne);
}
?>
</body>
</html>