I'm new to php and mysql I think I misplaced the mysqli_real_escape_string() I keep getting the following warning on line 3.
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in
Here is the php code.
<?php
$page = mysqli_real_escape_string($_SERVER['SCRIPT_FILENAME']);
// Query member data from the database and ready it for display
$mysqli = new mysqli("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"SELECT id page FROM mysql_counter_logs WHERE page = '$page'");
if (mysqli_num_rows($dbc) == 0) {
$mysqli = new mysqli("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"INSERT INTO mysql_counter_logs (page) VALUES ('$page')");
}
if ($dbc == 1) {
$dbc = mysqli_query($mysqli,"UPDATE mysql_counter_logs SET hits = hits + 1 WHERE page = '$page'");
}
//Retreives the current count
$count = mysqli_fetch_row(mysqli_query($mysqli,"SELECT hits FROM mysql_counter_logs"));
if (!$dbc) {
// There was an error...do something about it here...
print mysqli_error();
}
//Displays the count on your site
print "$count[0]";
?>
Also is there a way i can make this code more security proof from XSS attacks. Thanks