dtc88867 2017-02-28 14:25
浏览 13

php和mysql异常

I have a php page which is showing data in a HTML table taken from a MySQL database. Part of the table has a submit button for people to click to like a row. When clicked it runs a form which reloads the page and attempts to process the new inputs. In the example below all the inputs "submit", "timestamp" and "timestamp2" are set after the button is clicked. In the example the query $jpgh1 works and immediately reloads the row with the updated ticks count. If I use $jpgh2 the page reloads but is not updated. I have tried encasing $rt1 and $rt2 in quotes but that doesn't work. The reason I have the $admin bit is because this is being tested on a live system and I don't want the other users to see the testing. Currently the two values for timestamp and timestamp2 are being shown in the fields on the selected row and they match the values which work in $jpgh1.


if(isset($_POST['submit'])) {
    If((isset($_POST['timestamp'])) and (isset($_POST['timestamp2']))) {
        $rt1 = $_POST['timestamp'];
        $rt2 = $_POST['timestamp2'];

        $jpgh1 = mysql_query('update topics set ticks=1 where timestamp=1486723327    and timestamp2=1487081058');
        $jpgh2 = mysql_query('update topics set ticks=3 where timestamp=$rt1 and timestamp2=$rt2');
    }
}

<?php if($_SESSION['username'] == $admin) {
    $t1 = $dnn2['timestamp'];
    $t2 = $dnn2['timestamp2'];
    ?>
    <form action='' method='POST'>
        <input type='text' id='timestamp' name='timestamp' value='<?php echo $t1; ?>'/><br/>
        <input type='text' id='timestamp2' name='timestamp2' value='<?php echo $t2; ?>'/><br/>
        <input type='submit' name='submit' value='Tick'/></form>
    <?php
}
?>

Needless to say after I posted I found the answer.

if(isset($_POST['submit'])){
If((isset($_POST['timestamp'])) and (isset($_POST['timestamp2'])))
{
$rt1 = $_POST['timestamp'];
$rt2 = $_POST['timestamp2'];
$rt3 = "update topics set ticks=1 where timestamp=$rt1 and timestamp2=$rt2";
$jpgh3 = mysql_query($rt3);
}
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题