0

iphoneアプリケーションからmysqlにデータを挿入していますが、テーブルにデータを挿入していません。結果と入力された値をエコーし​​ますが、値も表示されません。

ページのHTMLコード

  <html>


  <head>
  <title>data to server</title>
  </head>
  <body>
  <form action="surveyAnswer.php" method="post" enctype="multipart/form-data"><br>

  <INPUT TYPE = "Text" VALUE ="1" NAME = "survey_question_response_id">

  <INPUT TYPE = "Text" VALUE ="1" NAME = "survey_id">
  <INPUT TYPE = "Text" VALUE ="1" NAME = "question_id">
  <INPUT TYPE = "Text" VALUE ="1" NAME = "survey_response_answer_id">
   <input type="submit" value="Upload File">
  </form>
  </body>
  </html>



     <?php
     $host = ""; 
     $user = ""; 
     $pass = ""; 
     $database = ""; 

     $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
     mysql_select_db($database, $linkID) or die("Could not find database."); 

     $survey_question_response_id=$_POST['survey_question_response_id'];
     $survey_id=$_POST['survey_id'];
     $question_id=$_POST['question_id'];
     $survey_response_answer_id=$_POST['survey_response_answer_id'];
     echo($survey_question_response_id);
     $query=("INSERT INTO survey_question_responses   (survey_question_response_id,survey_id,question_id,survey_response_answer_id)
     VALUES ('$survey_question_response_id', '$survey_id','$question_id','$survey_response_answer_id')");
     mysql_query($query,$con);
     printf("Records inserted: %d\n", mysql_affected_rows());
     echo($survey_id) 
    ?>
4

3 に答える 3

1

あなたのform方法は、変数をキャプチャするためにPOST使用しています。問題を解決する代わりに$_GET使用します。$_POST$GET

また、間違ったタグ構文。

<form action="surveyAnswer.php" method="post" enctype="multipart/form-data">

これは を指しsurveyAnswer.phpます。そのため、以下のコードをsurveyAnswer.phpページに配置し、html フォームが表示されているページから削除します。

    <?php

       $survey_question_response_id=$_POST['survey_question_response_id'];
       $survey_id=$_POST['survey_id'];
       $question_id=$_POST['question_id'];
       $survey_response_answer_id=$_POST['survey_response_answer_id'];
       $query=("INSERT INTO survey_question_responses     (survey_question_response_id,survey_id,question_id,survey_response_answer_id)
      VALUES ('$survey_question_response_id', '$survey_id','$question_id','$survey_response_answer_id')");
     mysql_query($query,$con);
     printf("Records inserted: %d\n", mysql_affected_rows());
     echo($survey_id);

 ?>
于 2012-08-03T07:20:04.320 に答える
0

アクションをPOSTで開始しますが、PHP コードでは $_GET を使用します

すべての $_GET を変更:

 <?php
   $survey_question_response_id=$_POST['survey_question_response_id'];
   // OR eighter to
   $survey_question_response_id=$_REQUEST['survey_question_response_id'];
   ....
于 2012-08-03T07:21:44.227 に答える
0

フォームのように、フォーム method="post" を持っています。ここで、GET を使用して値を保存しているので、フォーム method="GET" を変更するか、使用します

$_POST['survey_question_response_id'];  

それ以外の

$_GET['survey_question_response_id'];

他の変数についても同様です。

また、「;」がありません こちら「echo($survey_id)」

于 2012-08-03T07:23:39.300 に答える