Jump to content

could not update mysqli command


maideen
Go to solution Solved by mac_gyver,

Recommended Posts

Hi

 

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

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();                   
            }
    
    }

Link to comment
Share on other sites

hi ginerjm

 

I have echoed. It is fine. But the below error 

It is echoed. it is fine
500 Kinney 661.64 af blandit.mattis@nonleoVivamus.ca www.mujveqthwgg.oys supplier


Warning: mysqli_query(): Couldn't fetch mysqli in 
C:\xampp\htdocs\bkstore\customer\add_data.php on line 59

pls help me.

Link to comment
Share on other sites

  • Solution

the error you are getting typically occurs when you have closed the database connection and try to use the connection, i.e. $con was a connection, but that connection was closed prior to the code you have shown.

 

also, mysqli statements will only throw exceptions if you have used the mysqli_report() function/method to configure it to do so. your current code is a mix of the PDO logic you were previously using (why did you not keep using that?) and mysqli and as a result your catch(...){...} statement isn't going to work with mysqli exceptions (you also have an $ex vs $e variable name mismatch.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.