Brauch mal wieder hilfe.... in mysql...

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Brauch mal wieder hilfe.... in mysql...

    Hallo Leute kann mir einer helfen bei diesem Problem??

    PHP-Code:

    <?php
    $connect 
    mysql_connect('localhost''''');
    if (!
    $connect) {
        die(
    'keine Verbindung möglich: ' mysql_error());
    }

    if (
    CREATE TABLE `testpage`.`news` (`IDINT NOT NULL AUTO_INCREMENT PRIMARY KEY
    `
    titleVARCHAR(100NOT NULL
    `
    datumDATETIME NOT NULL
    `
    autorVARCHAR(50NOT NULL
    `
    inhaltTEXT NOT NULL,))
     
    {
        echo 
    "Datenbank Newspage erfolgreich angelegt\n";

    else {
        echo 
    "Fehler beim Anlegen der Datenbank testpage" mysql_error();
    }

     



    ?>
    Ich bekomme diese Fehlermeldung und weiß nicht woran es liegt....
    Parse error: syntax error, unexpected T_STRING in ...\test.php on line 7

  • #2
    dein query in der if-bedingung ist kein string. außerdem fehlt da noch ein mysql_query. so wird das nie was.

    gruß
    peter
    Nukular, das Wort ist N-u-k-u-l-a-r (Homer Simpson)
    Meine Seite

    Kommentar


    • #3
      und wie muss das richtig geschrieben werden??


      danke schonmal


      Gruß Terrorzwerg

      Kommentar


      • #4
        PHP-Code:
        if (CREATE TABLE `testpage`.`news` (`IDINT NOT NULL AUTO_INCREMENT PRIMARY KEY
        `
        titleVARCHAR(100NOT NULL
        `
        datumDATETIME NOT NULL
        `
        autorVARCHAR(50NOT NULL
        `
        inhaltTEXT NOT NULL,)) 
        Woher hast du das???
        Also wenn schon
        PHP-Code:
        $sql "CREATE TABLE `testpage`.`news` (`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
        `title` VARCHAR(100) NOT NULL, 
        `datum` DATETIME NOT NULL, 
        `autor` VARCHAR(50) NOT NULL, 
        `inhalt` TEXT NOT NULL,)"
        ;
        $res mysql_query($sql) OR die(mysql_error());
        if(!
        $res){
          die(
        'Fehler beim Anlegen der Datenbank');
        }else{
          die(
        'Datenbank wurde angelegt');

        Gruss

        tobi
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Kommentar


        • #5
          danke dir jahlives

          habe alles jetzt geändert,
          aber bekomme den jetzt den Fehler

          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 ')' at line 5



          PHP-Code:
          <?php
          $sql 
          mysql_connect('localhost''''');
          if (!
          $sql) {
              die(
          'keine Verbindung möglich: ' mysql_error());
          }

          $sql "CREATE TABLE `testpage`.`news` (`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
          `title` VARCHAR(100) NOT NULL, 
          `datum` DATETIME NOT NULL, 
          `autor` VARCHAR(50) NOT NULL, 
          `inhalt` TEXT NOT NULL,)"
          ;
          $res mysql_query($sql) OR die(mysql_error());
          if(!
          $res){
            die(
          'Fehler beim Anlegen der Datenbank');
          }else{
            die(
          'Datenbank wurde angelegt');
          }

          ?>
          danke schonmal für eure mühe

          Kommentar


          • #6
            TEXT NOT NULL,)";
            Komma weg, Fehler weg
            Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

            [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
            Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

            Kommentar


            • #7
              yo ich dank dir

              Kommentar


              • #8
                bekomme jetzt aber die Meldung

                Unknown Database "testpage"

                Kommentar


                • #9
                  HIER solltest du dich mal mit den Grundlagen vertraut machen.
                  Mein aktuelles Projekt: Hausaufgaben Datenbank für kostenlose Hausaufgaben

                  Kommentar


                  • #10
                    Solltest vor dem Anlegen der Tabelle wohl auch noch die DB anlegen. Ein Sql Query mit CREATE DATABASE name sollte ausreichen
                    Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

                    [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
                    Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

                    Kommentar


                    • #11
                      ja aber lege ich mit dem code nicht gleich ne neue tabelle mit den spalten an????

                      Kommentar


                      • #12
                        Mit einem CREATE TABLE legst du wohl kaum eine nichtvorhandene DB an
                        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

                        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
                        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

                        Kommentar

                        Lädt...
                        X