Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given... what i do wrong?

mysqli_real_escape_string() expects parameter 1 to be mysqli, null given
mysqli_select_db() expects exactly 2 parameters, 1 given in
mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given codeigniter
mysqli_query() expects at least 2 parameters, 1 given
call to undefined function mysql_real_escape_string()
uncaught error: call to undefined function mysql_real_escape_string()
mysqli_error() expects exactly 1 parameter
mysqli_query() expects parameter 2

I try make php login but i get this error: Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given, what I do wrong?

register.php

<!doctype html>
<html lang"fi">
<head>
<link rel="icon" type='image/png' href='images/logo.png'>
<title>
asd
</title>
<link href="css/styles.css" type="text/css" rel="stylesheet">
</head>
<body>
<!--reg alkaa-->
<form action="register.php" method="post">
<p><input type="text" name="username" placeholder="Username">
<p><input type="email" name="email" placeholder="Email">
<p><input type="password" name="pass" placeholder="Password">
<p><input type="password" name="pass1" placeholder="Password">
<p><input type="submit" name="submit" value="Register">
</form>
<?php

if(isset($_POST['submit']))
{
$username = mysqli_real_escape_string($_POST['username']);
$pass = mysqli_real_escape_string($_POST['pass']);
$pass1 = mysqli_real_escape_string($_POST['pass1']);
$email = mysqli_real_escape_string($_POST['email']);
if($username && $pass && $pass1 && $email)
{
if($pass==$pass1)
{
    $connect = mysql_connect("mysql.example.com","username","password");
    mysql_select_db("my_database");
    $query = mysql_query("INSERT INTO users VALUES('$username','$pass','$email');");
    echo "You have been registered.";
}
else
{
    echo "Password must match.";
}
}
else
{
echo "All fields are required.";
}
}
 ?>
<!--reg end-->
<Center>
<a href="index.php">
<h1>
asd
</h1>
</center>
<div id="main">
<h3>
 <div class="menu"> <a href="index.php">Etusivu</a> &bullet; 
 <a                                       </div>
</h3>
</div>
<div class="jonne"> 
</div>
<script src="javascript/jquery.js"></script>
</body>
</html>

i use 000webhost and this first time when i use mysql databases online.

You are mixing mysqli and mysql function.

If your are using mysql function then instead mysqli_real_escape_string($your_variable); use

$username = mysql_real_escape_string($_POST['username']);
$pass = mysql_real_escape_string($_POST['pass']);
$pass1 = mysql_real_escape_string($_POST['pass1']);
$email = mysql_real_escape_string($_POST['email']);

If your using mysqli_* function then you have to include your connection to database into mysqli_real_escape function :

$username = mysqli_real_escape_string($your_connection, $_POST['username']);
$pass = mysqli_real_escape_string($your_connection, $_POST['pass']);
$pass1 = mysqli_real_escape_string($your_connection, $_POST['pass1']);
$email = mysqli_real_escape_string($your_connection, $_POST['email']);

Note : Use mysqli_* function since mysql has been deprecated. For information please read mysqli_*

mysqli_real_escape_string() expects exactly 2 parameters in mysqli , Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in on line 139 Warning: mysqli_fetch_assoc() expects parameter 1 to be Of course, some people still use it as there are valid reasons to do so, There's nothing wrong with using mysqli_real_escape_string() instead of� Checking google or the php manual would have told you to add the variable, which holds the mysqli link ressource, to mysqli_real_escape_string. – Charlotte Dunois May 22 '16 at 15:07 Please start using Prepared, Parameterized Queries.

From the documentation , the function mysqli_real_escape_string() has two parameters.

string mysqli_real_escape_string ( mysqli $link , string $escapestr ).

The first one is a link for a mysqli instance (database connection object), the second one is the string to escape. So your code should be like :

$username = mysqli_real_escape_string($yourconnectionobject,$_POST['username']);

mysqli_real_escape_string() expects exactly 2 parameters, 1 given , mysqli_real_escape_string() expects exactly 2 parameters, 1 given Fatal Error - php. I am working on a registration form and am using PHP 5.6. on line 13 Warning: mysqli_query() expects at least 2 parameters, 1 given in in table name i.e. FROM 'login_details' is wrong. try $email=mysql_real_escape_string($ email);� Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in F:\wamp64\www\gmdb\searchj.php on line 10 Call Stack Kostas Konstantinidis May 30, 2017 03:20AM

mysqli_real_escape_string function requires the connection to your database.

$username = mysqli_real_escape_string($your_connection, $_POST['username']);

P.S.: Do not mix mysql_ functions* and mysqli_ functions*. Please use mysqli_* functions or PDO because mysql_* functions are deprecated and will be removed in the future.

php Warning: mysqli_real_escape_string() expects exactly 2 , php Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given what i do wrong? Question. All Note Code Video Articles. mysqli_real_escape_string() expects exactly 2 parameters It required a database resource as the first parameter. Of course no one uses it any more as by using prepare and bind the data can be kept

you are mixing mysql and mysqli

use this mysql_real_escape_string like

$username = mysql_real_escape_string($_POST['username']);

NOTE : mysql_* is deprecated use mysqli_* or PDO

trouble with php script: err : mysqli_real_escape_string() expects , error message:Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /usr/local/www/apache22/acctdata/compsearch.php on line 21 499, , , , , , 0, () compsearch.php.txt Appears I was wrong. Look at Example#2� This error is very straight forward - it is telling you that the function was expecting, in this case, 2 parameters, and you only supplied 1. It won't work unless you supply what it needs. If all

If you use the procedural style, you have to provide both a connection and a string:

$name = mysqli_real_escape_string($conn, $name);

Only the object oriented version can be done with just a string:

$name = $link->real_escape_string($name);

The documentation should hopefully make this clear.

Mysqli_real_escape_string() expects exactly 2 parameters, 1 given, Hello, any one can help me or guide how to fix this issue. I'm getting this error: Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in� I have a secured area of my site where I can add/update/delete database entries. I am trying to update the script from mysql to mysqli. Everything works except for the "update" part.

Solved: Converting to MYSQLI - Adobe Support Community, Home 1; Programming Forum 2; Web Development Forum Warning: mysql_real_escape_string() expects parameter 1 to be string Is there anything wrong in the� I try make php login but i get this error: Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given, what I do wrong? register.php &lt;!doctype html&gt; &lt;html lang"fi"&gt; &lt;

Solved: I am trying to convert an old site to use mysqli rather than mysql. Hit a bit of a stumberling block Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in Could someone please tell me what I am doing wrong. Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\XAMPP\htdocs\XXX.php on line 18 Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\XAMPP\htdocs\XXX.php on line 28 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\XAMPP\htdocs\XXX.php on line 30

uccessfullyConnected successfully Warning: session_start(): Cannot send session expects exactly 2 parameters, 1 given… what i do wrong? Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

Comments
  • For avoid the special characters use java script validation in front end.
  • That's not a safe way of escaping strings for MySQL.
  • mysql has been deprecated