Php Can';t获取AJAX表单以提交MySQL数据

Php Can';t获取AJAX表单以提交MySQL数据,php,javascript,mysql,ajax,Php,Javascript,Mysql,Ajax,我有两个文件: <?php include('db.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-

我有两个文件:

<?php
include('db.php');


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Generic Title</title>
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$(".edit_tr").click(function()
{
var ID=$(this).attr('id');
$("#time_"+ID).hide();
$("#character_"+ID).hide();
$("#message_"+ID).hide();
$("#status_"+ID).hide();
$("#time_input_"+ID).show();
$("#character_input_"+ID).show();
$("#message_input_"+ID).show();
$("#status_input_"+ID).show();
}).change(function()
{
var ID=$(this).attr('id');
var time=$("#time_input_"+ID).val();
var character=$("#character_input_"+ID).val();
var message=$("#message_input_"+ID).val();
var status=$("#status_input_"+ID).val();
var dataString = 'id='+ ID +'&time='+ time + '&character='+ character + '&message='+ message+ '&status='+ status;
$("#character_"+ID).html('<img src="load.gif" />');


if(time.length>0 && message.length>0 && character.length>0 && status.length>0)
{
$.ajax({
type: "POST",
url: "table_edit_ajax.php",
data: dataString,
cache: false,
success: function(html)
{

$("#time_"+ID).html(time);
$("#character_"+ID).html(character);
$("#message_"+ID).html(message);
$("#status_"+ID).html(status);
}
});
}
else
{
alert('Enter something.');
}

});

$(".editbox").mouseup(function() 
{
return false
});

$(document).mouseup(function()
{
$(".editbox").hide();
$(".text").show();
});

});
</script>
<style>
body
{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
}
.editbox
{
display:none
}
td
{
padding:7px;
}
.editbox
{
font-size:14px;
width:135px;
background-color:#ffffcc;

border:solid 1px #000;
padding:4px;
}
.edit_tr:hover
{
background:url(edit.png) right no-repeat #80C8E5;
cursor:pointer;
}


th
{
font-weight:bold;
text-align:left;
padding:4px;
}
.head
{
background-color:#333;
color:#FFFFFF

}

</style>

</head>

<body bgcolor="#dedede">
<div style="margin:0 auto; width:750px; padding:10px; background-color:#fff; height:800px;">
<table width="100%">
<tr class="head">
<th>Time</th><th>Character</th><th>Message</th><th>Status</th>
</tr>
<?php
$sql=mysql_query("select * from script");
$i=1;
while($row=mysql_fetch_array($sql))
{
$id=$row['id'];
$character=$row['character'];
$time=$row['time'];
$message=$row['message'];
$status=$row['status'];

if($i%2)
{
?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<?php } else { ?>
<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
<?php } ?>
<td width="10%" class="edit_td">
<span id="time_<?php echo $id; ?>" class="text"><?php echo $time; ?></span>
<input type="text" value="<?php echo $time; ?>" class="editbox" id="time_input_<?php echo $id; ?>" />
</td>
<td width="25%" class="edit_td">
<span id="character_<?php echo $id; ?>" class="text"><?php echo $character; ?></span> 
<input type="text" value="<?php echo $character; ?>"  class="editbox" id="character_input_<?php echo $id; ?>"/>
</td>
<td width="55%" class="edit_td">
<span id="message_<?php echo $id; ?>" class="text"><?php echo $message; ?></span> 
<input type="text" value="<?php echo $message; ?>"  class="editbox" id="message_input_<?php echo $id; ?>"/>
</td>
<td width="10%" class="edit_td">
<span id="status_<?php echo $id; ?>" class="text"><?php echo $status; ?></span> 
<input type="text" value="<?php echo $status; ?>"  class="editbox" id="status_input_<?php echo $id; ?>"/>
</td>
</tr>

<?php
$i++;
}
?>

</table>
</div>
</body>
</html>

通用标题
$(文档).ready(函数()
{
$(“.edit_tr”)。单击(函数()
{
var ID=$(this.attr('ID');
$(“#时间”+ID).hide();
$(#字符#+ID).hide();
$(“#消息"+ID).hide();
$(“#状态#”+ID).hide();
$(“#时间#输入#”+ID).show();
$(#字符#输入#+ID).show();
$(“#消息"输入"+ID).show();
$(#状态#输入#+ID).show();
}).change(函数()
{
var ID=$(this.attr('ID');
var time=$(“#time_input_uu”+ID).val();
var character=$(“#character_input”+ID).val();
var message=$(“#message_input_u”+ID).val();
var status=$(“#status_uinput_uu”+ID).val();
var dataString='id='+id+'&time='+time+'&character='+character+'&message='+message+'&status='+status;
$(“#字符"+ID).html(“”);
if(time.length>0&&message.length>0&&character.length>0&&status.length>0)
{
$.ajax({
类型:“POST”,
url:“table_edit_ajax.php”,
数据:dataString,
cache:false,
成功:函数(html)
{
$(“#time"+ID).html(time);
$(“#字符"+ID).html(字符);
$(“#消息"+ID).html(消息);
$(“#状态"+ID).html(状态);
}
});
}
其他的
{
警惕(“输入某物”);
}
});
$(“.editbox”).mouseup(函数()
{
返回错误
});
$(文档).mouseup(函数()
{
$(“.editbox”).hide();
$(“.text”).show();
});
});
身体
{
字体系列:Arial、Helvetica、无衬线字体;
字体大小:14px;
}
.编辑框
{
显示:无
}
运输署
{
填充:7px;
}
.编辑框
{
字体大小:14px;
宽度:135px;
背景色:#ffffcc;
边框:实心1px#000;
填充:4px;
}
.edit_tr:悬停
{
背景:url(edit.png)右不重复#80C8E5;
光标:指针;
}
th
{
字体大小:粗体;
文本对齐:左对齐;
填充:4px;
}
.头
{
背景色:#333;
颜色:#FFFFFF
}
TimeCharacterMessageStatus
字符是MySQL中的一个字符。如果你想使用它,你需要用反勾号来转义它

UPDATE script SET time='$time', `character` = '$character' ...

将其放在PHP脚本的顶部,用于生产
ini\u集('display\u errors','On');错误报告(E_全部)UPDATE script SET time='$time', `character` = '$character' ...