Instantly share code, notes, and snippets.

@romelemperado /mysqlcon.php Secret
Last active Nov 28, 2016

Embed
What would you like to do?
<?php
function mysqlquery($query,$dbcon,$returnValue = false){
$result = $dbcon->query($query);
if(!$result){
die('There was an error running the query [' . $dbcon->error . ']');
}
//Do not use `fetch_assoc()` in INSERT query to prevent
//`PHP Fatal error: Call to a member function fetch_assoc() on a non-object` error.
if($returnValue){
return $result->fetch_assoc();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment