Ciao,

premetto che ho 3 tabelle strutturate nel seguente modo:

ts_utenti:

username
...

ts_registrazione:

username
...

ts_bannati:

username
...

Io, quando un utente si registra, volevo verificare se il nome utente da lui desiderato non era per caso gia' inserito in quale altra tabella. Ad. esempio perche' esiste gia' un utente con lo stesso nome oppure e' nella lista dei ban.

Ed avevo scritto la seguente cosa:

Codice PHP:
// Controllo se non esiste gia'
$query="SELECT count(*) AS tot FROM ts_utenti, ts_registrati, ts_bannati WHERE username='$username'";
$result mysql_query($query$db);
$row mysql_fetch_array($result)
if(
$row[tot]>0)
  
$errore.="- Nome utente gia' esistente
"

Solo che mi da errore, quindi non funziona

Momentaneamente ho messo la seguente soluzione, ma ormai non e' ottimale

Codice PHP:
// Controllo se non esiste gia'
$query="SELECT count(*) AS tot FROM ts_utenti WHERE username='$username'";
$result mysql_query($query$db);
$row_1 mysql_fetch_array($result);

$query="SELECT count(*) AS tot FROM ts_registrazione WHERE username='$username'";
$result mysql_query($query$db);
$row_2 mysql_fetch_array($result);

$query="SELECT count(*) AS tot FROM ts_bannati WHERE username='$username'";
$result mysql_query($query$db);
$row_3 mysql_fetch_array($result);

if((
$row_1[tot]+$row_2[tot]+$row_3[tot])>0)
  
$errore.="- Nome utente gia' esistente
"

Qualcuno potrebbe darmi una dritta per avere un'unica chiamata al database?