PHP更新单元格数据错误
PHP Update Cell Data Error
嘿嘿嘿!
我遇到了这个问题,由于某种原因,它不会将数据添加到我的MYSQL数据库中,我不知道为什么。我在StackOverflow上看了很多其他帖子,但似乎找不到对我有帮助的帖子:)
这是我的代码:
<script>
$('.alert-saved-changes-success2').hide();
$(".save-tradelink-profile").click(function() {
$tradelinkvalue = document.getElementById("tradelink").value;
if ($.trim($('#tradelink').val()) == '') {
alert('Tradelink can not be blank');
} else if ($tradelinkvalue.indexOf("https://steamcommunity.com/tradeoffer/new") >= 0) {
<?php //TRYING TO UPDATE DATA
$TradelinkValue = $_POST['GetTradelinkValue'];
mysql_query("UPDATE item-jackpot-users SET tradelink=$TradelinkValue WHERE steam_id=$steamid") or die(mysql_error());
?>
$("#alert-saved-changes-success").slideDown("slow");
} else {
alert('Tradelink has to be valid');
}
});
$(".logout-button-profile").click(function(){
window.location.href = "steamauth/logout.php";
});
</script>
php标签似乎比其他标签先加载,因为
$('.alert-saved-changes-success2').hide();
未加载。它发现了错误,然后就扼杀了其他一切。
考虑到php是在你的网络浏览器接收到js文本之前执行的,你可以使用一个表单,将你的更新信息发送到post中(比如使用表单标签),重新加载页面,并让页面用你的post数据执行更新。您也可以使用ajax。
<form name="login" class="form-horizontal" method="post" action="refer to this file" >
<div class="form-group">
<label class="col-sm-3 control-label">
Username
</label>
<div class="col-sm-2">
<input class="pull-right" type="text" name="username" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">
Password
</label>
<div class="col-sm-2">
<input class="pull-right" type="password" name="password" />
</div>
</div>
<div class="form-group">
<div class=" col-sm-offset-3 col-sm-2">
<button type="submit" name="submitbtn" class="btn btn-default pull-right">
Sign in
</button>
</div>
</div>
</form>
<?php
$user = $_POST['username'];
$pwd = $_POST['password'];
//DO SOME SANITIZATION!
//Store $user and $pwd
?>
当然,您可以在文件的其他地方包括php部分,比如在脚本标记中。
相关文章:
- 巨大的数据和PHP错误
- 本地跨原点数据错误
- d3在数据更新时错误地附加了dom元素
- 使用odata 4的jaydata 1.5和保存/更新数据时的错误
- 正在检查ajax响应中的错误数据
- Modx数据包管理器ext-all.js错误
- 尝试使用.ninnerHTMLlog打印数据,获取错误Uncaught TypeError:undefined不是函数
- 加载json时出现Ember.js和Ember数据错误
- JavaScript运行时错误:完成此操作所需的数据尚不可用
- 尝试发布大型JSON数据时出现错误请求错误
- 挖空错误:数据保留未定义
- 未定义 D3 错误数据
- 未捕获的引用错误:数据未在挖空中定义
- jquery .ajax 总是返回错误 - 数据被添加到数据库中
- 类型与未定义相比的错误 - 数据为空
- jQuery ajax json——查看返回的错误数据
- 从模拟端口读取时从Arduino串行接收到的错误数据
- 如何在socket io中向单个客户端发送错误数据包?
- Dropzone JS上传到WCF获取错误数据
- 在收到错误数据后清空剑道UI中的网格