2010-11-24 18 views
-1

以下の電子メールクエリは、 "ttemail"というフィールドが0になるとトリガされるはずです。使用しようとすると、私はYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1を取得しています。IF文からのMySQLエラー

電子メールがなぜttemail = 0

少なくとも最初のユーザ名のための任意のアイデアを送信しているように見えますか?事前に

おかげで、

ジョン

if($row["ttemail"] == 0){ 
    $mailaddress = $row['email']; 
    $link1 = "<a href='http://www...com/page.php'>Page Title</a>"; 
    $message1 = "Congratulations, message. 

       <br> 
       <br> 

       More Message 

       <br> 
       <br> 

       Please click the link below to see more. 
       <br> 
       <br> 

       $link1 
       ";  

    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    $headers .= "From: Website Name <[email protected]>" . "\r\n"; 

    $queryem = mail($mailaddress, "Congratulations, message 
          $submission.", $message1, $headers); 

    //$ttquery = sprintf("Update login SET ".$row['ttemail']." = '1' WHERE username = ".$row['username']."");   

    mysql_query($queryem) or die(mysql_error()); 
    mysql_query($ttquery) or die(mysql_error()); 
} else { 
} 
+3

お待ちください。あなたはMySQLのクエリとして 'mail()'への呼び出しの戻り値を使用していますか? – EboMike

+2

ブール値をクエリとして使用したいですか? = P – MatTheCat

+1

昨日同じ質問をしたことがありませんでしたが、無意味なPHPソースコードの代わりに生成されたクエリを表示するように質問しましたか? –

答えて

0

私はあなたがあなたのwhere句に「欠けていると思います。下記の訂正された質問を確認してください -

$ttquery = sprintf("Update login SET ".$row['ttemail']." = '1' WHERE username = '".$row['username']."'");