【问题标题】:Mysql update difficultymysql更新难度
【发布时间】:2012-09-13 20:35:57
【问题描述】:

我正在尝试修复我的邀请系统。当用户登录系统时,系统会创建一个$_SESSION['id'],然后脚本会检查inviteid 行中是否有任何值。

如果有系统检查用户的积分是否超过1000。如果他有系统则使用inviteid为推荐人更新积分。

<?php session_start();
ob_start();
error_reporting(0);
include("dbConn.php");
?>
<?php
    if(isset($_SESSION['id'])){
?>
<?php
   $unuserid = $_SESSION['id'];
   $sql="select * from users WHERE id = $unuserid"; 
   $result = mysql_query("SELECT * FROM users WHERE id='$unuserid'");
   while($row = mysql_fetch_array($result))
   {
    $unPOINTS = $row['points'];
    $uninviteid = $row['inviteid'];

    } 

     if(isset($uninvited)) {

     ?>

<?php
  if ($unPOINTS > 1000) {
?>
<?php
    $sql="UPDATE users SET points = $unPOINTS + 500 WHERE id = $uninviteid";
    $result=mysql_query($sql) or die(mysql_error()."<br />".$sql); 
    header("Location: index.php?page=changemember&id=$UID");
}   }


?>

<?php
    }
?>

【问题讨论】:

  • 摆脱error_reporting(0);!不要隐藏错误消息 - 改为编写干净的代码。
  • WebnetMobile.com 谢谢,我会摆脱它。没有真正关注error_repoting(0);

标签: php mysql referrer


【解决方案1】:

你在第 26 行有一个错字,应该是:

if(isset($uninviteid)) {

您可以通过使用 Eclipse 或 NetBeans 等 IDE 进行开发来避免此类错误。

并尝试使用 Zend 编码标准来格式化您的 PHP 代码,这将使您的生活更轻松。阅读更多:http://framework.zend.com/manual/1.12/en/coding-standard.html

【讨论】:

  • 谢谢。你真的帮了我。不敢相信我更改了代码一百次,这是一个很小的拼写错误。再次感谢
猜你喜欢
  • 2011-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-04
相关资源
最近更新 更多