Ciao ragazzi, ho scritto questo codice per aggiornare dei campi di una table:
Codice PHP:
<?php
$host
="localhost";
$username="root";
$password="";
$database="vetture";

$conn=mysql_connect($host,$username,$password);
mysql_select_db($database) or die("Impossibile selezionare il database");
 
if(
$_POST && isset($_GET['id']))
{
aggiorna_record();}
elseif(isset(
$_GET['id']))
{
mostra_record();}
else
    
mostra_lista();
 
function 
mostra_lista()
{
    if(isset(
$_GET['msg']))
        echo 
'[b]'.htmlentities($_GET['msg']).'[/b]

'
;

    
$query "SELECT id,uid,upwd FROM members";
    
$result mysql_query($query);
    if (!
$result) {
        die(
"Errore nella query $query: " mysql_error());
    }
    echo 
'
    <table border="1">
        <tr>
            <th>id</th>
            <th>utente</th>
            <th>password</th>
            <th></th>
        </tr>'
;
     while (
$row mysql_fetch_assoc($result))
    {
        
$id=htmlspecialchars($row['id']);
        
$uid=htmlspecialchars($row['uid']);
        
$upwd=htmlspecialchars($row['upwd']);
        
$link $_SERVER['PHP_SELF'] . '?id=' $row['id'];
 
        echo 
"<tr>
                <td>
$id</td>
                <td>
$uid</td>
                <td>
$upwd</td>
                <td><a href=\"
$link\">modifica</a></td>
            </tr>"
;
    }
    echo 
'</table>';
    
mysql_free_result($result);
    
mysql_close();
}

function 
aggiorna_record()
{
    
// recupero i campi di tipo "stringa"
    
$id=intval($_GET['id']);
    
$uid=trim($_POST['uid']);
    
$upwd=trim($_POST['upwd']);
 
    
// preparo la query
    
$query "UPDATE members SET uid='$uid', upwd='$upwd', WHERE id=$id";
    
$result mysql_query($query);
    if (!
$result) {
        die(
"Errore nella query $query: " mysql_error());
    }
    
mysql_close($conn);
 
    
$messaggio urlencode('Aggiornamento effettuato con successo');
    
header("location: $_SERVER[PHP_SELF]?msg=$messaggio");
}


function 
mostra_record()

    
$id intval($_GET['id']);
    
$query "SELECT id,uid,upwd, FROM members WHERE id = $id";
    
$result mysql_query($query);
    if (!
$result
    { die(
"Errore nella query $query: " mysql_error()); }
    
    if(
mysql_num_rows($result) != 1
    { die(
"l'ID passato via GET è errato"); }
 
    list(
$uid,$upwd,)=mysql_fetch_row($result);
 
    
$uid=htmlspecialchars($uid);
    
$upwd=htmlspecialchars($upwd);

 echo 
"
      utente
      <input name='utente' type='text' value=<?php echo 
$uid?>/>
      password
      <input name='password' type='text' value=<?php echo 
$upwd?>/>
      <input name='invia' type='submit' value='Invia'/> "
};
?>
Ora quando lo vado ad eseguire mi da il seguente errore:
Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\upd.php on line 96
Sembra che manchi una parentesi, una virgola o un punto e virgola ma vedendolo non vedo dove...
Mi date una manina a trovare l'intoppo perchè magari a me sfugge qualcosa?