获取错误mysql_fetch_array()期望参数1为资源

时间:2016-02-04 16:47:12

标签: javascript php

编辑数据时出现警告类型错误。 php抛出警告:mysql_fetch_array()期望参数1是资源。

帮助我解决它我是php的新手。

<?php
    include_once 'connection.php';
    if(isset($_GET['edit_id'])) {
        $sql_query="SELECT * FROM users WHERE user_id=".$_GET['edit_id'];
        $result_set=mysql_query($sql_query);
        $fetched_row=mysql_fetch_array($result_set);
    }
    if(isset($_POST['btn-update'])) { 
        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $city_name = $_POST['city_name'];

        sql_query = "UPDATE users SET first_name='$first_name',last_name='$last_name',user_city='$city_name' WHERE user_id=".$_GET['edit_id'];

        if(mysql_query($sql_query)) {
?>
            <script type="text/javascript">
                alert('Data Are Updated Successfully');
                window.location.href='index.php';
            </script>
<?php
        } else {
?>
            <script type="text/javascript">
                alert('error occured while updating data');
            </script>
<?php
        } 
    }
    if(isset($_POST['btn-cancel'])) {
        header("Location: index.php");
    }
?>

0 个答案:

没有答案