0

次のエラーで失敗しているサーバー側で実行される php コードを含めました。

解析エラー: 構文エラー、/home3/atljj/public_html/Osler/include/vo2_membersite.php 行 2849 の予期しない T_ELSE

ELSEステートメントで停止している理由がわからない???

短い話... 1 レコードの MYSQL 制御ファイルを作成して維持するプログラムを書きたいと思っています。

私は段階的にコードを書いていますが、これまでのところ:

  1. フォームを介して HTML コードを記述し、適切なフィールドを持つテーブルを作成する要求をサーバーに送信します。

  2. 次に、INSERT ステートメントを介して最初のレコードをテーブルに書き込むように、サーバーが書き直されました。

  3. ここまでは順調です... MySQL ファイルに 1 つのレコードがあり、次はそれを更新するだけです。

  4. サーバーは、既存のレコードをテストするように変更されました。その場合は、INSERT コードをバイパスし、代わりに UPDATE コードを実行します。

テーブルのチェックが間違っていますか?レコード 1 を検索していますが、見つからない場合は INSERT ELSE を使用し、UPDATE を使用します...

function UpdateCase(&$formvars)
{
    $con = mysqli_connect($this->db_host,$this->username,$this->pwd,$this->database);
    if (mysqli_connect_errno())
    {
        $this->HandleDBError("Failed to connect to MySQL");
        return false;
        }
    $c_match = $this->RandomIt();
    $c_username = "admin";

    $qry = "Select * from $this->case_c_table WHERE c_id = 1";
    if(!$result = mysqli_query($con,$qry));
    { /* first entry not found add to table*/
        $c_flag="M";
        $addit = 'INSERT INTO $this->case_c_table (
            c_match,
            c_flag,
            c_username,
            c_element,
            c_patname,
            c_patgndr,
            c_patage,
            c_patethncty,
            c_patdate,
            c_cc,
            c_td,
            c_lmpdate
            )
            values
            (
            "' . $c_match . '",
            "' . $c_flag . '",
            "' . $c_username . '",
            "' . $this->SanitizeForSQL($formvars['c_element']) . '",
            "' . $this->SanitizeForSQL($formvars['c_patname']) . '",
            "' . $this->SanitizeForSQL($formvars['c_patgndr']) . '",
            "' . $this->SanitizeForSQL($formvars['c_patage']) . '",
            "' . $this->SanitizeForSQL($formvars['c_patethncty']) . '",
            "' . $this->SanitizeForSQL($formvars['c_patdate']) . '",
            "' . $this->SanitizeForSQL($formvars['c_cc']) . '",
            "' . $this->SanitizeForSQL($formvars['c_td']) . '",
            "' . $this->SanitizeForSQL($formvars['c_lmpdate']) . '"
            )';      
        mysqli_query($con,$addit);
    }
    else
    {
        $qry="Update $this->case_c_table Set
        c_element=". $this->SanitizeForSQL($formvars['c_element']).",
        c_patname=". $this->SanitizeForSQL($formvars['c_patname']).",
        c_patgndr=". $this->SanitizeForSQL($formvars['c_patgndr']).",
        c_patage=" . $this->SanitizeForSQL($formvars['c_patage']).",
        c_patethncty=". $this->SanitizeForSQL($formvars['c_patethncty']).",
        c_patdate=". $this->SanitizeForSQL($formvars['c_patdate']).",
        c_cc=". $this->SanitizeForSQL($formvars['c_cc']).",
        c_td=". $this->SanitizeForSQL($formvars['c_td']).",
        c_lmpdate=". $this->SanitizeForSQL($formvars['c_lmpdate'])."
        WHERE c_id=1";
        mysqli_query($con,$qry);
    }
}
4

0 に答える 0