I am trying to check if tuple data exists before entering the data into the database columns. I am trying mysql_query and getting errors that I should be using mysqli, but it does not seem to be working for me.
This is my code so far
foreach ($AllData as $sigleData) {
$table = $sigleData['name'];
$columns = implode(", ", $sigleData['columns']);
$columnData = implode(" ',' ", $sigleData['data']);
//insert into database tuple data
$sqlQuery = "INSERT INTO " . $table . " ( " . $columns . ") VALUES( '" . $columnData . "')";
if ($dbConnectionT->query($sqlQuery) == TRUE) {
echo "database updated";
echo "</br>";
}
}
I have this function :-
function check_tuple_exists($table){
global $dbConnectionT; // connection to database
$sql = "SELECT ALL FROM '".$table."'";
$res = $dbConnectionT->query($sql);
if ($res->num_rows > 0)
{ // output data of each row
while($row = $res->fetch_assoc()) {
echo "data " . $columnData . "<br>";
}
} else
{
echo "0 results";
}
}
but it gives me this error:- Trying to get property of non-object