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

Can we see more of the code?  Did you make an sql connection?  The message - where did that come from?  The message seems incomplete - it mentions a fetch, but your fetch command is commented out.

 

Too sketchy to determine.

Link to comment
Share on other sites

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

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.