doulou9927 2014-12-03 09:25
浏览 29

MySQL查询和php问题

I've got a problem with data I get from my query. Doesnt matter how many records match to the SELECT I use, it always return me 0 value.

<html>
<body>
<link rel="stylesheet" href="mystyle.css">
<meta charset="utf-8"> 
<head>
  <title>Lottery</title>
</head>
<?php
if(isset($_POST['submit'])){
$value = $_POST['Value'];  
echo "Chosen value : " .$value;  
}

?>


<div class="results">
<p>Counter: <? echo "".$value ?></p>
<p>Place: <? echo "".$value ?>: </p>
<p>Best match<? echo "".$value ?> :</p>
</div>



        <?
    $servername = "localhost";
    $username = "lottery_root";
    $password = "xyz";
    $database = "lottery";
    $conn = mysqli_connect($servername, $username, $password, $database) or die(mysqli_error($conn));



    $result = mysqli_query($conn, "Select count(*) from lottery where first='$_POST[value]' or      second='$_POST[value]'; ");
    if (!$result) echo mysqli_error($conn);

    $row = mysqli_fetch_row($result);
    print_r($row);
    ?>
    </body>
    </html>

This is what I get each time " Array ( [0] => 0 ) " If I use different SELECT, for example SELECT * FROM lottery; it prints one column.

  • 写回答

3条回答 默认 最新

  • dongsheng9203 2014-12-03 09:29
    关注

    $_POST['Value'] is different than $_POST['value']

    Its case sensitive, you have to use exact name of input field, as you have it named in the form.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line