Visualizzazione risultati 1 fino 9 di 9

Discussione: eliminare tabella se esiste gia

  1. #1
    Guest

    Predefinito eliminare tabella se esiste gia

    in una pagina c'è questo..

    $sql = mysql_query("
    CREATE TABLE $nome (
    id int(25) NOT NULL default '$vita',
    ) TYPE=MyISAM;");

    come metto che prima controlla se c'è gia, poi se esiste gia la elimina e la ricrea, mentre se non esiste la crea e basta?

  2. #2
    Guest

    Predefinito

    ins't anyone here?

  3. #3
    L'avatar di Evcz
    Evcz non è connesso Utente storico
    Data registrazione
    31-05-2002
    Residenza
    Vicenza
    Messaggi
    5,670

    Predefinito

    prima la fai cancellare se esiste:
    DROP TABLE IF EXISTS 'nometabella'
    poi la crei con la stringa che hai postato tu
    There are three kinds of people in this world: people who watch things happen ... people who complain about things that happen ... and people who make things happen...

  4. #4
    Guest

    Predefinito

    ho provato a inserire

    $elimina = mysql_query("DROP TABLE IF EXISTS '$nome'");

    ma non funge!

  5. #5
    L'avatar di Evcz
    Evcz non è connesso Utente storico
    Data registrazione
    31-05-2002
    Residenza
    Vicenza
    Messaggi
    5,670

    Predefinito

    che errore ti da?
    There are three kinds of people in this world: people who watch things happen ... people who complain about things that happen ... and people who make things happen...

  6. #6
    Guest

    Predefinito

    nessuno... semplicemente non elimina la tabella!

  7. #7
    Guest

    Predefinito

    ho provato a mettere:

    if ($elimina) {
    echo "Ciao";
    } else {
    echo "Mignottone";
    }
    e compare mignottone!

  8. #8
    L'avatar di Evcz
    Evcz non è connesso Utente storico
    Data registrazione
    31-05-2002
    Residenza
    Vicenza
    Messaggi
    5,670

    Predefinito

    nessun errore????

    no..

    devi fare

    echo mysql_error();

    dopo aver lanciato la query...
    There are three kinds of people in this world: people who watch things happen ... people who complain about things that happen ... and people who make things happen...

  9. #9
    Guest

    Predefinito

    mi dice questo:

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXIST 'Gorg'' at line 1

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •