INSERT - PHP & SQL-Server

Ich weiß nicht, was Los ist, aber es will einfach nicht funktionieren.

Ich bekomme immer diese Fehlermeldung, wenn ich meine form:

Array ( [0] => Array ( [0] => 22001 [SQLSTATE] => 22001 [1] => 8152 [code] => 8152 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Zeichenfolgen-oder Binärdaten würden abgeschnitten werden. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Zeichenfolgen-oder Binärdaten würden abgeschnitten werden. ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 3621 [code] => 3621 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Die Anweisung wurde beendet. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Die Anweisung wurde beendet. ) )

Hier ist die PHP Code:

    <?php
$who = $_REQUEST["who"];
$what = $_REQUEST["what"];

$serverName = "xxx";   
$uid = "xxx";     
$pwd = "xxx";    
$databaseName = "xxx";   

$connectionInfo = array( "UID"=>$uid,                              
                         "PWD"=>$pwd,                              
                         "Database"=>$databaseName);   

/* Connect using SQL Server Authentication. */    
$conn = sqlsrv_connect( $serverName, $connectionInfo);    

$tsql = "insert into Suggestions (Who, What, Votes) values ('$who','$what','10')";   

/* Execute the query. */    

$stmt = sqlsrv_query( $conn, $tsql);    

if ( $stmt )    
{    
     $something = "Submission successful.";
}     
else     
{    
     $something = "Submission unsuccessful.";
     die( print_r( sqlsrv_errors(), true));    
}
    $output=$something;
/* Free statement and connection resources. */    
sqlsrv_free_stmt( $stmt);    
sqlsrv_close( $conn);
?>

Und hier ist das HTML-Formular:

<form action="startvoting.php" method="post" id="myform">
          <ol>
            <li>
              <label for="name">Nickname</label>
              <input id="who" name="who" class="text" />
            </li>
            <li>
              <label for="message">What <strong>you</strong> Want</label>
              <textarea id="what" name="what"></textarea>
            </li>
            <li class="buttons">
              <input type="image" src="images/send.gif" class="send" />
              <div class="clr"></div>
            </li>
          </ol>
        </form>

Kann mir bitte jemand helfen? Ich weiß nicht, was zu tun ist!

Danke

UPDATE

Ist hier die Definitionen:

TABLE_QUALIFIER TABLE_OWNER TABLE_NAME  COLUMN_NAME DATA_TYPE   TYPE_NAME   PRECISION   LENGTH  SCALE   RADIX   NULLABLE    REMARKS COLUMN_DEF  SQL_DATA_TYPE   SQL_DATETIME_SUB    CHAR_OCTET_LENGTH   ORDINAL_POSITION    IS_NULLABLE SS_DATA_TYPE
DB_11967_suggestions    dbo Suggestions Who 12  varchar 1   1           1           12      1   1   YES 39
DB_11967_suggestions    dbo Suggestions What    12  varchar 1   1           1           12      1   2   YES 39
DB_11967_suggestions    dbo Suggestions Votes   4   int 10  4   0   10  1           4           3   YES 38

Sorry, es ist nicht richtig formatiert.

  • Können Sie uns zeigen die definition der Tabelle, wie gut? Die SQL für diese ist DESCRIBE Suggestions
  • Du meinst: sp_help suggestions oder sp_columns suggestions - DESC/BESCHREIBEN, ist Oracle/MySQL
  • Getan habe ich aktualisiert, Frage mit ihm 🙂
InformationsquelleAutor | 2010-08-17
Schreibe einen Kommentar