I've seen this error posted everywhere and no one's answers seem to pertain to mine. This is my code:
<?php
$password=$_POST['password'];
$check=$_POST['checkid'];
$con=mysqli_connect("db","dbuser","$password","db","3306");
//Gives player a new loadout
function playerLoadout()
{
mysqli_query($con,"INSERT INTO cust_loadout_profile (cust_loadout_id, unique_id)
VALUES
('$_POST[loadoutid]','$_POST[uniqueid]')");
}
//Updates existing player's loadout
function updateLoadout()
{
mysqli_query($con,"UPDATE cust_loadout_profile SET cust_loadout_id='$_POST[loadoutidchange]'
WHERE unique_id='$_POST[uniqueidchange]'");
}
//Creates new loadout
function createLoadout()
{
mysqli_query($con,"INSERT INTO cust_loadout (id, inventory, backpack, description) VALUES ('$_POST[id]','$_POST[inventory]','$_POST[backpack]','$_POST[description]')");
}
//Deletes selected loadout
function deleteLoadout()
{
mysqli_query($con,"DELETE FROM cust_loadout WHERE id = '$_POST[iddelete]'");
}
//Table that shows current loadouts
mysql_connect("db","dbuser","password");
mysql_select_db("db");
$data = mysql_query("SELECT * FROM `cust_loadout_profile` WHERE `unique_id` = '$check' ")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
Print "Current Loadout: ".$info['cust_loadout_id'] . " ";
}
if (!empty($_POST['uniqueid'])) { playerLoadout(); }
if (!empty($_POST['uniqueidchange'])) { updateLoadout(); }
if (!empty($_POST['id'])) { createLoadout(); }
if (!empty($_POST['iddelete'])) { deleteLoadout(); }
?>
and the mysqli_query() expects parameter 1 to be mysqli, null given error occurs on line 28 which is this query:
mysqli_query($con,"INSERT INTO cust_loadout (id, inventory, backpack, description) VALUES ('$_POST[id]','$_POST[inventory]','$_POST[backpack]','$_POST[description]')");
any ideas what is causing this error? $con is defined at the beginning of the code and it doesn't give me that error for the first two functions, just this third one.