Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

could not update mysqli

General discussions related to php

Moderators: macek, egami, gesf

could not update mysqli

Postby maideen » Mon Apr 07, 2014 6:26 am

Hi
I have another issue in Update. Could not be updated. pls help me


Code: Select all
if (isset($_POST['update']) && $_POST['update']  != "" )
   
    {
        $id=$_POST["id"];
        $name = $_POST["name"];
        $address = $_POST["address"];
        $tel = $_POST["tel"];
        $fax = $_POST["fax"];
        $email = $_POST["email"];
        $website = $_POST["website"];
        $type = $_POST["type"];   
 
 
        try
            {
            $sql="UPDATE bk_customer SET name='$name',address='$address', tel='$tel',fax='$fax',email='$email', website='$website',type='$type' WHERE id='$id'";
                    $result = mysqli_query($con,$sql) ;
//                    $result=mysqli_fetch_assoc($con,$sql);
           
            }
        catch (Exception $ex)
            {
              echo $e->getMessage() . "\n";
              file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
              exit();                   
            }
   
    }

maideen
New php-forum User
New php-forum User
 
Posts: 27
Joined: Mon Mar 07, 2011 11:38 pm

Re: could not update mysqli

Postby adicooldude » Mon Apr 07, 2014 10:23 am

hi,
1) check your database column names with the ones your using .
2) try echoing the update query and manually run the query in database .
adicooldude
New php-forum User
New php-forum User
 
Posts: 10
Joined: Mon Apr 07, 2014 2:26 am

Re: could not update mysqli

Postby peterachutha » Sat May 31, 2014 11:53 pm

Looks like you have a missing ;

WHERE id='$id'";

I think should be

WHERE id='$id' ; ";

But try this out also as this worked for me but I do not know why.

WHERE id='".$id."' ;";
peterachutha
New php-forum User
New php-forum User
 
Posts: 10
Joined: Sat May 31, 2014 10:35 pm


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.