maideen Posted April 7, 2014 Share Posted April 7, 2014 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(); } } Quote Link to comment https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/ Share on other sites More sharing options...
ginerjm Posted April 7, 2014 Share Posted April 7, 2014 how do you know it failed? Do you get a message - no because you didn't check your query results and issue one. Quote Link to comment https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/#findComment-1475262 Share on other sites More sharing options...
maideen Posted April 8, 2014 Author Share Posted April 8, 2014 hi ginerjm I have echoed. It is fine. But the below error It is echoed. it is fine500 Kinney 661.64 af blandit.mattis@nonleoVivamus.ca www.mujveqthwgg.oys supplierWarning: mysqli_query(): Couldn't fetch mysqli in C:\xampp\htdocs\bkstore\customer\add_data.php on line 59pls help me. Quote Link to comment https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/#findComment-1475387 Share on other sites More sharing options...
ginerjm Posted April 8, 2014 Share Posted April 8, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/#findComment-1475400 Share on other sites More sharing options...
Solution mac_gyver Posted April 9, 2014 Solution Share Posted April 9, 2014 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.) Quote Link to comment https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/#findComment-1475462 Share on other sites More sharing options...
maideen Posted April 9, 2014 Author Share Posted April 9, 2014 thanks mec_gyver Once removed mysqli_close($con); it works fine Tq. Quote Link to comment https://forums.phpfreaks.com/topic/287584-could-not-update-mysqli-command/#findComment-1475498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.