dowdw44426 2013-05-21 18:09
浏览 42
已采纳

MySQL / PHP Update语句输出白页,没有错误

Im trying to update records in my table with the followin, my problem is however that my browser outputs an empty white page with no source, Can anybody see what I'm doing wrong?

<?php

require 'dbconfig.php';

//Always place this code at the top of the Page
session_start();
if (!isset($_SESSION['id'])) {
    // Redirection to login page twitter or facebook
    header("location: index.php");
}



function safe($value){
   return mysql_real_escape_string($value);
}

// Variables
$_SESSION['username'];
$_SESSION['oauth_provider'];
$uid = $_SESSION['id'];
$email = safe($_POST["email"]);
$credits = safe($_POST["credits"]);



 $query = mysql_query("UPDATE users SET email= '$email' WHERE id='$uid'") or die(mysql_error());


?>
  • 写回答

3条回答 默认 最新

  • douchuilai2355 2013-05-21 18:11
    关注

    You have assigned a variable to your query, but you are not running it.

     $query = mysql_query("UPDATE users SET email= '$email' WHERE id='$uid'") or die(mysql_error());
    

    So, the above is just a redundant code. to run it, you should call $query, like this

    if($query){
    echo 'Updated performed';
    }else{
    echo 'Update failed';
    }
    

    Note I'm not encouraging you to use mysql_ functions as they are weak, vulnerable and deprecated. Intead you should learn more about PDO

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题