www.webdeveloper.com
Results 1 to 2 of 2

Thread: why could not be able to update...

Threaded View

  1. #1
    Join Date
    Aug 2006
    Posts
    57

    why could not be able to update...

    hi, I tried to change update query from mysql to mysqli, at first under mysql is works great to update into mysql database but when i changed to mysqli is not doing update it. can anyone tell me what did i missed!

    under mysql

    PHP Code:
    <?php
    include('db.php');
    if(isset(
    $_GET['status']))
    {
    $status1=$_GET['status'];
    $select=mysql_query("select * from manage where id='$status1'");
    while(
    $row=mysql_fetch_object($select))
    {
    $status_var=$row->status;
    if(
    $status_var=='0')
    {
    $status_state=1;
    }
    else
    {
    $status_state=0;
    }
    $update=mysql_query("update manage set status='$status_state' where id='$status1' ");
    if(
    $update)
    {
    header("Location:index.php");
    }
    else
    {
    echo 
    mysql_error();
    }
    }
    ?>
    <?php
    }
    ?>

    and under mysqli

    PHP Code:
    <?php
    include('db.php');
    $dbcs = new mysqli($mysql_hostname$mysql_user$mysql_password$mysql_database);
    if(isset(
    $_GET['status']))
    {
    $status1=$_GET['status'];

      
    $sql "select * from product where product_id='$status1'";
      
    $result=mysqli_query($dbcs,$sql);

    while(
    $row=mysqli_fetch_object($result))
    {
    $status_var=$row->status;
    if(
    $status_var=='0')
    {
    $status_state=1;
    }
    else
    {
    $status_state=0;
    }

    $mysqli->query("UPDATE product set status='$status_state' where product_id='$status1' ");
    if(
    $mysqli)
    {
    header("Location:item.php");
    }
    else
    {
    echo 
    mysqli_error();
    }
    }
    ?>
    <?php
    }
    ?>
    Last edited by Alidad; 01-03-2014 at 08:38 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles