There isnt an actual error, but it's still displaying an error message when a user who is not the buyer or seller goes to the page. Is it possible to suppress the error message?
Direct link to images
//transaction id
$transactionid = $_GET['id'];
//Retrieve info about transaction
$query = "SELECT ads.*, feedback.*, transactions.* FROM (ads INNER JOIN transactions ON ads.id=transactions.ad_id) INNER JOIN feedback ON transactions.id=feedback.transaction_id WHERE transaction_id = '$transactionid'";
$data = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($data);
$seller = $row['seller'];
$buyer = $row['buyer'];
//check if user is buyer or seller
if ($_SESSION['user_id'] == $seller) {
$query = "SELECT * FROM feedback WHERE transaction_id = '$transactionid' AND seller_comment IS NULL";
$data1 = mysqli_query($dbc, $query);
} else if ($_SESSION['user_id'] == $buyer) {
$query = "SELECT * FROM feedback WHERE transaction_id = '$transactionid' AND buyer_comment IS NULL";
$data1 = mysqli_query($dbc, $query);
}
//if user is buyer/seller echo form to them to submit feedback
if (mysqli_num_rows($data1) == 1) {
echo '<p><form method="post" action="feedback.php?id=' . $transactionid . '&action=submitfeedback">
<textarea id="feedback" name="feedback" rows="10" cols="30"></textarea><br/>
<input type="submit" value="Submit" name="submit" /></form></p>';
} else {
echo '<p>feedback already given</p>';
}
You may want to resolve the warning, not just cover it up. You should be able to resolve this by changing the if statement to:
if(!empty($data1) && mysql_num_rows($data1) == 1) {
The problem is trying to pass NULL to the mysql function.
@mysqli_num_rows
@ suppresses errors for that function
it is best to remove the source of the error.
if (false !== $data1 && 1 === mysqli_num_rows($data1)) {
// submit comment
} else {
// comment already submitted
}
What if $_SESSION['user_id']
does not equal $seller
OR $buyer
. Then $data1
never gets set and is null when passed into num_rows
.
To suppress it put an @ before the function, like:
@mysqli_num_rows(...)
OR check for !$data
before you do the num_rows
:
if(!$data) {
// not a buyer or seller
} else {
// do the mysqli_num_rows
}
I would do the latter, it is much cleaner and clear.
Try putting something like the following in your php.ini file:
display_errors = Off
log_errors = On
error_log = "error.log"
This will suppress error messages from being displayed on pages and instead output them to a logfile.