douren4075 2015-04-08 19:36
浏览 59

PHP查询仅返回null(在线phpmyadmin)

i tried to run these codes manually at url but it returns null values

1.when admin accept the request status will be updated as in first query

2.second query will fetched remain_leave

3.third query will update the found difference from remain_leave and
ldays

<?php
 $con=mysql_connect("","","");
$db=mysql_select_db('',$con);

$status=$_REQUEST['status'];
$eid=$_REQUEST['eid'];
$ldays=$_REQUEST['ldays'];
$leave=0;

 $result=mysql_query("update user_request set status='$status' where eid  
 ='$eid'") or die("error");

$result1=mysql_query("select remain_leave  from user where id='$id'");

while($row= mysql_fetch_assoc($result1))
{
$leave=$row['remain_leave'];

}

$diff=$leave-$ldays;

$result=mysql_query("update user set remain_leave=$diff where id    
='$eid'") or die("error");


echo json_encode($respon);
?>
  • 写回答

1条回答 默认 最新

  • douzhong4222 2015-04-08 20:30
    关注
    select remain_leave  from user where id='$id'
    

    $id isn't defined, so it will always be running this query

    select remain_leave  from user where id=''
    

    Also note that

    mysql_query and related functions are deprecated and slated for removal in a later release. mysqli or PDO are recommended in its place

    And that if $id is meant to come from the user like $eid then directly inserting it into the query like that is vulnerable to SQL injection. See: What is SQL injection?

    As mentioned by Fred -ii in the comments, $respon is also undefined in your final echo

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度