Bradley Dale Bradley Dale - 6 months ago 26
PHP Question

Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in

I do apologise if it's messy but if anyone can go correcting stuff in their I shall be very appreciated of it!

Error Line


Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\wamp\www\PTT\login.php on line 28


Line of code

$voornaam = mysqli_real_escape_string($_POST['voornaam']);


Short slice of coding.

//Generate a key, print a form:
$key = sha1(microtime());
$_SESSION['csrf'] = $key;


if(isset($_POST['registreer'])){
$voornaam = mysqli_real_escape_string($_POST['voornaam']);
$achternaam = mysqli_real_escape_string($_POST['achternaam']);
$land = mysqli_real_escape_string($_POST['land']);
$gebdate = mysqli_real_escape_string($_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']);
$inlognaam = mysqli_real_escape_string($_POST['inlognaam']);
$wachtwoord = mysqli_real_escape_string($_POST['wachtwoord']);
$wachtwoord_nogmaals = mysqli_real_escape_string($_POST['wachtwoord_nogmaals']);
$wachtwoordmd5 = md5($wachtwoord);
$email = mysqli_real_escape_string($_POST['email']);
$wereld = mysqli_real_escape_string($_POST['wereld']);
$secondaccount = mysqli_real_escape_string($_POST['agreecheck']);
$schelden = mysqli_real_escape_string($_POST['agreecheck2']);

$ip = $_SERVER['REMOTE_ADDR'];
$date = date("Y-m-d H:i:s");
$character = mysqli_real_escape_string($_POST['character']);
$referer = mysqli_real_escape_string($_POST['referer']);
$check = mysqli_fetch_assoc(mysqli_query("SELECT `ip_aangemeld`, `aanmeld_datum` FROM `gebruikers` WHERE `ip_aangemeld`='".$ip."' ORDER BY `user_id` DESC"));
$registerdate = strtotime($check['aanmeld_datum']);
$current_time = strtotime(date('Y-m-d H:i:s'));
$countdown_time = 604800-($current_time-$registerdate);

Answer

like the warning says: you are missing an argument in mysqli_real_escape_string, you should add your db connection as an argument:

    $voornaam    = mysqli_real_escape_string($connection, $_POST['voornaam']);
Comments