problema update sql

Bruce5000

Utente Attivo
14 Ott 2007
106
0
0
Ciao, ho questo script php, il mio problema è che non riesco a far aggiornare il database con update.
Potete aiutarmi?
Codice:
<?php
session_start();
ob_start();
include ("../connessione.php");
include ("funzioni.php");

if (isset($_SESSION['password']))
{
include("../connessione.php");

$userid=1;
if (isset($_GET['userid'])){
  $userid=$_GET['userid'];
}
$queryUtente=mysql_query("select * from webs_user where userID = ".$userid);
$utente=mysql_fetch_array($queryUtente);

<form name="post" action="veragestione.php?pagina=gestionenewsletter&paginanewsletter=nuovanewsletter" method="post" enctype="multipart/form-data"  onSubmit="return chkFormular()">
<input type="hidden" name="userid" value="<?=$userid?>">

<table align="left" width="200">
<tr bgcolor="#003366">
<td class="tahbol" width="120" align="center">Username</td>
<td class="tahbol" width="120" align="center">Nickname</td>
</tr>
<?php
$utenti=mysql_query("select * from webs_user order by nickname");
$giri=0;
while ($utente=mysql_fetch_array($utenti))
{
$giri++;

?>
<tr bgcolor="#e9e7e7">
<td class="tahnormal" width="120" align="left"><?php echo $utente['username']; ?></td>
<input type="hidden" name="<?=$utente['username']; ?>" value="<?=$utente['username']; ?>">
<td class="tahnormal" width="120"  align="left"><?php echo $utente['nickname']; ?></td>
<td class="tahnormal"><input type="checkbox" value="utente<?=$utente['userID']; ?>" name="utente<?=$utente['userID']; ?>"/></td>

</tr>
<?php
  
  }
?>


</table>

<table width="600px" border="0" cellspacing="1" cellpadding="2" class="tahbol" align="right">
    <tr bgcolor="#003366"> 
      <td align="center" class="tahbolb">INVIO NUOVA NEWSLETTER</td>
    </tr>
    
    <tr> 
      <td>
      </td>
    </tr>
    
    
    <tr>
      <td>
        <hr noshade size="1" color="#666666">
      </td>
    </tr>
    
    <tr>
      <td colspan="3">
        <table width="600px" border="0" cellspacing="0" cellpadding="2"  align="center">
          <tr> 
            <td align="center"><b>Rubrica: </b> 
            <select name="rubrica">
            <option value="logonewsletter" selected>Newsletter</option>
            <option value="logotnc">Redazione</option>
            </select>
              <b>
              Carica immagine
              </b>
              <input type="file" name="imgnewsletter" class="formbutton">
              <!--<b>
                Allineamento
              </b>
              <select name="alignimg">
              <option value="left" selected>Left</option>
              <option value="center">Center</option>
              <option value="right">Right</option>
              </select> 
     -->
            </td>
          </tr>
          <!--
          <tr>
              <td align="center"><b>Dimensioni: </b>
              larghezza <input type="text" name="larg" size="3">
              altezza <input type="text" name="alt" size="3">
              </td>
          </tr>
              -->      
          <tr>
            <td align="center">
            <hr noshade size="1" color="#666666">
            </td>
          </tr>
          
          <tr>
            <td align="left"><b>
              Titolo: 
    </b>
    </td>
  </tr>
    <tr>
     <td>
              <input name="headline1" type="text" size="119" class="form_off" onFocus="this.className='form_on'" onBlur="this.className='form_off'">

            </td>
          </tr>
          <tr>
            <td align="left"><b>
              Descrizione: 
    </b>
    </td>
  </tr>          
          <tr> 
            <td align="center">
            <textarea name="message" rows="20" cols="90" class="form_off" onFocus="this.className='form_on'" onBlur="this.className='form_off'">inserisci testo</textarea>
              <br> 
            </td>
          </tr>
                       
          <tr> 
            <td colspan="5">
            <hr noshade size="1" color="#666666">
            </td>
          </tr>
          
          <tr align="center"> 
            <td colspan="2">            
           <input type="submit" name="invia" value="Invia">
            </td>
          </tr>
        </table>
    </td>
  </tr>
</table>
</form>
<?php

if (isset($_POST['invia'])) {
    $rubricanewsletter=$_POST['rubrica'];
    $titolonewsletter=$_POST['headline1'];
 $newsletter=$_POST['utente'.$utente['userID']];
 $username=$_POST[$utente['username']];
 if($_FILES['imgnewsletter']['name']!="") {
  $messaggio=immagine($_FILES['imgnewsletter'],140,140,366,196);
  if ($messaggio=="true") {
   $immagine=$_SESSION['nomeimmagine'];      
  }
  else $immagine="";
 } 
 else $immagine="";


    $testonewsletter=$_POST['message'];
    $datanewsletter=date('d-m-Y - H:i');
    $posizione="archivio";
 
    mysql_query("insert into newsletter (data,titolo,testo,immagine,logo)
    values ('$datanewsletter','$titolonewsletter','$testonewsletter','$immagine','$rubricanewsletter')"); 

 $sel = isset($newsletter) ? '1' : '0';
if($sel == '1'){
        mysql_query("update webs_user set invio_newsletter = '1' where username = ".$username);

?>
  <script type="text/javaScript">
 alert("Campo modificato!")
 </script>
<?php
}
   }
}
?>
 
prova:
PHP:
mysql_query("update webs_user set invio_newsletter = '1' where username = ".$username) or die (mysql_error());
e vedi che errore ti restituisce.
 

Discussioni simili