1

初めて投稿しますが、これが他の人にも役立つことを願っています。このトピックに関する投稿をいくつか見つけましたが、かなり具体的な問題が発生しているようです。

これはPHPでの私の出力です

質問=「ツバメ」はどの鳥の別の名前ですか?/どのスポーツで「ウェスタン ロール」が見られますか?/「ハーバート カウリー」としてよく知られているのは誰ですか?/「ダイエット」はどの国の議会ですか? /ココ シャネルの本名は?/「アステカ人」はどの国の原住民ですか?/1869 年に「OA North」によって発明されたものは?/ゾグ王はどの国の支配者でしたか?&answers=カモメ/ペンギン/アジサシ/鵜&正解=0/0/1/0&

そして、これは私のAS3コードです

     var         request:URLRequest = new             
URLRequest("http://localhost:8888/Quiz/questions.php");
            request.method = URLRequestMethod.GET;

            var loader2:URLLoader = new URLLoader();
            loader2.addEventListener(Event.COMPLETE, completeHandler);
            loader2.dataFormat = URLLoaderDataFormat.TEXT;
            loader2.load(request);


            function completeHandler(event:Event) :void{

            var questions1 = event.target.data.questions1;

            // dynamic text box called username

            questionbox.question.text=event.target.data.questionbox.question.text;

            }

            var questions:String;
            var questionsArray:Array=questions.split("/");

動的テキスト ボックスに質問を表示しようとしていますが、エラー コード #2007 Parameter text must be non-null が表示されます。

文字列を配列に変換しようとしています。

誰でもここで問題を見ることができますか?

どんな助けでも大歓迎です!前もって感謝します

編集:

これは私のPHPコードです

<?php
//functions

function get_id($column, $table)
{
 $sql    = mysql_query("select $column FROM $table") ;
 while ($row    =mysql_fetch_array($sql))
 {
  return $row["ID"];
 }
}

function getquestions($id)
{
 $sql    =mysql_query("select text FROM questions WHERE quiz_ID =$id ");
 $questions   = array();
 while($row   = mysql_fetch_row($sql))
 {
  $questions[] = $row[0];
 }
 return $questions;
}

function getanswers($id)
{
 $sql    = mysql_query("select answer FROM answers WHERE question_ID= $id ");
 $answers = array();
 while($row    =mysql_fetch_row($sql))
 {

  $answers[] = $row[0]; 
 }

 return $answers;
}

function getcorrect($id)
{
 $sql    = mysql_query("SELECT correct FROM answers WHERE question_ID= $id ");
 $correct   =array();
 while($row    =mysql_fetch_assoc($sql))
 {
  $correct[]    =$row["correct"]; 
 }
   return $correct;
}


//Connect to Database
$con = mysql_connect("localhost","dinita","3nd3m0luk");

if(!$con)
{
 die('Could not connect: '.mysql_error());
}

else
{

 // SELECT DATABASE
mysql_select_db("quizCreation", $con);

// Create an array of data from database


$quizid    = get_id("ID","quizName");
$questionid    = get_id("ID", "questions");
$ques   = implode("/",getquestions($quizid));
$ans    =implode("/",getanswers($questionid)); 
$cor    =implode("/", getcorrect($questionid));


echo htmlentities( "questions"."=". $ques."&");
echo htmlentities("answers"."=".$ans."&");
echo htmlentities("correct"."=".$cor."&");

}

mysql_close($con); 

?>
4

1 に答える 1

0

それがあなたのphpコードの出力である場合、それをテキストフィールドで視覚化する必要がある場合は、次のように変更する必要があります:

        var questions:String = event.target.data.questions;
        questionbox.question.text=questions;

文字列を配列として変換する場合は、次のようにします。

       var questionsArray:Array=questions.split("/");
于 2012-10-11T16:05:20.793 に答える