I don't know how PHP functions work. I have this function:
function runQueryMeta($tabelM, $metaName, $id_post, $metaValue, $check_ok_M){
$result = $conn -> query("SELECT * FROM ".$tabelM." WHERE post_id=".$id_post." AND meta_key='".$metaName."'");
if ($result->num_rows > 0){
$conn -> query("UPDATE ".$tabelM." SET meta_value='".$metaValue."' WHERE post_id='".$id_post."' AND meta_key='".$metaName."'");
}else {
$conn -> query("INSERT INTO ".$tabelM." (post_id, meta_key, meta_value) VALUES ('".$id_post."', '".$metaName."', '".$metaValue."')");
}
$check_ok_M = 1;
$result -> free_result();
return $check_ok_M;
}
I have this call for the function:
$nume_ok = runQueryMeta('mnsa_usermeta', 'nume_organizatie_companie', $item_id, $_POST['f_nume']);
And i have this function that connects to the database:
function OpenCon(){
$dbhost = "host";
$dbuser = "user";
$dbpass = "pass";
$db = "db";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
return $conn;
}
with this call
$conn = OpenCon();
But i have this error: Failed to load resource: the server responded with a status of 500 ()
when i run the first fuction.