Text in SQL speichern

Dieses Thema im Forum "Webentwicklung" wurde erstellt von Mooshka, 23. Juni 2008 .

Schlagworte:
Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 23. Juni 2008
    Hier erst einmal meine Dateien:


    settings.php
    PHP:
    <? php

        error_reporting
    ( E_ALL );

        
    define ( 'MYSQL_HOST' ,      'localhost' );
        
    define ( 'MYSQL_USER' ,      'user' );
        
    define ( 'MYSQL_PASS' ,      'pass' );
        
    define ( 'MYSQL_DATABASE' 'db' );


    mysql_connect ( MYSQL_HOST MYSQL_USER MYSQL_PASS ) or  system_error ( 'ERROR: Can not connect to MySQL-Server' );
    mysql_select_db ( MYSQL_DATABASE )or  system_error ( 'ERROR: Can not connect to database "' . MYSQL_DATABASE . '"' );


    ?>

    neu.php
    PHP:
    < html >
    <
    head >
    <
    title > neu </ title >
    </
    head >
    <
    body >
    <
    form method = "post"  action = "action.php" >
    <
    input name = "witz"  type = "text"  id = "witz"  value = "witz"  />
     <
    input type = "submit"  name = "submit"  value = "abschicken"  />
    <
    input type = "reset"  name = "felder_loeschen"  value = "löschen" >
    </
    form >
    </
    body >
    </
    html
    action.php
    PHP:
    <html>
    <head>
    <title>Speichern in DB</title>
    </head>

    <body>
    <?php
    include( "settings.php" );
    echo 
    $_POST [ 'witz' ];

    $sql  'INSERT INTO
        Witze(ID, WITZ, DATUM)
    VALUES
        (NULL,
         $_POST['
    witz '],
         NOW());'
    ;
            
    ?>



    </body>
    </html>

    Jetzt mein Problem:
    Der Text wird dank
    PHP:
    echo  $_POST [ 'witz' ];
    zwar angezeigt, aber nicht in der Tabelle gespeichert. Wo ist mein Fehler?


    bw ist selbstverständlich
     
  2. 23. Juni 2008
    AW: Text in SQL speichern

    bitte einmal die grundlagen verinnerlichen, danke.
     
  3. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.