the-real-sumsome /
witter
| 1 | <?php |
||
| 2 | function getAllPendingFriendRequests($useranme, $connection) { |
||
| 3 | $stmt = $connection->prepare("SELECT * FROM friends WHERE reciever = ? AND status = 'p'"); |
||
| 4 | $stmt->bind_param("s", $useranme); |
||
| 5 | $stmt->execute(); |
||
| 6 | $result = $stmt->get_result(); |
||
| 7 | $user = $result->fetch_assoc(); |
||
| 8 | if($result->num_rows === 0) return('You have no incoming friend requests.'); |
||
| 9 | $stmt->close(); |
||
| 10 | |||
| 11 | return $user; |
||
| 12 | } |
||
| 13 | |||
| 14 | function getSendNameFromFriendRequest($id, $connection) { |
||
| 15 | $stmt = $connection->prepare("SELECT sender FROM friends WHERE id = ?"); |
||
| 16 | $stmt->bind_param("s", $id); |
||
| 17 | $stmt->execute(); |
||
| 18 | $result = $stmt->get_result(); |
||
| 19 | while($row = $result->fetch_assoc()) { |
||
| 20 | $sender = $row['sender']; |
||
| 21 | } |
||
| 22 | return $sender; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 23 | $stmt->close(); |
||
|
0 ignored issues
–
show
$stmt->close() is not reachable.
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed. Unreachable code is most often the result of function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last Loading history...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | function getRecNameFromFriendRequest($id, $connection) { |
||
| 27 | $stmt = $connection->prepare("SELECT reciever FROM friends WHERE id = ?"); |
||
| 28 | $stmt->bind_param("s", $id); |
||
| 29 | $stmt->execute(); |
||
| 30 | $result = $stmt->get_result(); |
||
| 31 | while($row = $result->fetch_assoc()) { |
||
| 32 | $rec = $row['reciever']; |
||
| 33 | } |
||
| 34 | return $rec; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 35 | $stmt->close(); |
||
|
0 ignored issues
–
show
$stmt->close() is not reachable.
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed. Unreachable code is most often the result of function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last Loading history...
|
|||
| 36 | } |
||
| 37 | ?> |
||
|
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. Loading history...
|