ok so I am reading in JSON data and want to insert it into a database and this is what I have. It comes back and says
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result
meaning the SQL statement is wrong, but I don't know whats wrong with it.
foreach($json_o->roster as $data)
{
//echo "{$data[0]} {$data[1]} {$data[2]}";
//echo "<br>";
require_once ('mysqli_connect.php');
$q = "INSERT INTO roster (character, effortP, gearP) VALUES ('$data[0]', '$data[1]', '$data[2]')";
$r = mysqli_query ($dbc, $q);
if (mysqli_num_rows($r) == 1) {
echo "All entry additions added successfully!";
}else{
mysqli_rollback($dbc);
}
}
}
$dbc is in the mysqli_connect.php file.
it holds all my database connection info then sets it
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result
meaning the SQL statement is wrong, but I don't know whats wrong with it.
foreach($json_o->roster as $data)
{
//echo "{$data[0]} {$data[1]} {$data[2]}";
//echo "<br>";
require_once ('mysqli_connect.php');
$q = "INSERT INTO roster (character, effortP, gearP) VALUES ('$data[0]', '$data[1]', '$data[2]')";
$r = mysqli_query ($dbc, $q);
if (mysqli_num_rows($r) == 1) {
echo "All entry additions added successfully!";
}else{
mysqli_rollback($dbc);
}
}
}
$dbc is in the mysqli_connect.php file.
it holds all my database connection info then sets it
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );