UPDATE查询无法运行php + mysql [关闭]

I am trying UPDATE to update my data with the following code. There might be problem in UPDATE query, but I checked syntax, modified it, but still its not working. Please Help.

FORM.php

<?php
require_once 'conn.php';
$var = $_GET['q'];
$varmod = 'tid="'.$var.'"';
$query = "SELECT * FROM temptable WHERE $varmod";
$result = mysql_query($query, $db) or die(mysql_error($db));
while ($row = mysql_fetch_assoc($result)) {
    $head = $row['thead'];
    $text = $row['ttext'];
    echo "<div id='main'>";
    echo "<form action='show.php?q=".$row['tid']."' method='POST'>";
    echo "<textarea name='thead' id='thead'>$head</textarea><br>";
    echo "<textarea name='ttext' >$text</textarea><br>";
    echo "<input type='submit' value='Update' /></form></div>";
}
?>

show.php

<?php
$title = $_POST['thead']; 
$text = $_POST['ttext'];
$date = date("Y-m-d");  
require_once 'conn.php';

if(isset($title)){  
    if (isset($_GET['q'])) {
        $temp = $_GET['q'];
        $query = "UPDATE temptable SET thead=\"$title\" AND ttext=\"$text\" WHERE tid=\"$temp\"";
    }
    else{
    $query= "INSERT INTO temptable
    (thead, ttext, tdate) 
    VALUES (\"$title\", \"$text\", \"$date\")";
    }
    $result = mysql_query($query, $db) or die(mysql_error($db));
}

Well INSERT query is working well.

Mysql Update queries must be like this ;

"UPDATE targettable SET column='$var1', column2='$var2' WHERE targetcolumn='$target'";

Try this it will help you..

use ,(comma) instead of AND in your update query then it will work fine.

"UPDATE temptable SET thead='".$title."', ttext='".$text."' WHERE tid='".$temp."' ";