Jump to content

could not update mysqli command


maideen

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
https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/
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 [email protected] 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.

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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.