Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

震昌 asked in 社會與文化語言 · 1 decade ago

PHP不知道哪裡有問題= =

<?

include ("config.php");

$query = "select * from $managertable where name = '$PHP_AUTH_USER' and passwd = '$PHP_AUTH_PW' ";

$result = mysql_query($query);

$numRows = mysql_num_rows($result);

if ($numRows == 1 && !empty($PHP_AUTH_USER)) {

$str_test="select * from $testtable where test_no='$test_no'";

$result_test = mysql_query($str_test,$link);

$row_test=mysql_fetch_row($result_test);

list($tid,$test_name,$test_no,$test_status,$passwd,$create_date,$question_total,$question_total_now,$question_no,$ans_no,$creater)=$row_test;

$prob=split(":",$question_no); //分解題目

$right_ans=split(":",$ans_no); //分解答案

$str_std_ans="select std_ans,score from std_ans_$test_no where std_no='$std_no'";

$result_std_ans = mysql_query($str_std_ans,$link);

$row=mysql_fetch_row($result_std_ans);

list($std_ans,$score)=$row;

$ans_tok=split(":",$std_ans);

$yes=0;

$no=0;

for ($i=0;$i<$question_total;$i++)

if ($ans_tok[$i]==$right_ans[$i]) //判斷對錯

$yes++;

else

$no++;

}

?>

Update:

上面的抓不到資料= = 不知道哪裡有問題

如果絕得不夠完整我在把整個檔案用上來

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    $str_std_ans="select std_ans,score from std_ans_$test_no where std_no='$std_no'";

    請問std_ans_$test_no 這是一個變數還是資料庫名稱

    如果是變數錢字符號應該在最前面,如果是資料庫

    名稱的話也盡量不要用特殊符號,麻煩你將config.php

    也一起貼出來吧,這樣比較有頭有尾,比較好找錯誤,

    還有$PHP_AUTH_USER這個變數是從哪裡來的,如果

    不是在config.php裡的話也請你一併貼上來吧。

    Source(s): 自己
Still have questions? Get your answers by asking now.