mysql - I cannot use mysql_* functions after upgrading PHP -


I'm having some problems with PHP upgrades. Before that, I was using PHP 5.2.0 and below ; Now I've upgraded to PHP 5.5.0. I do not expect as some of my snippets.

Here's one, for example. It says,

deprecated: mysql_real_escape_string ()

I tried mysqli_real_escape_string () and found another error: / P>

WARNING: mysqli_real_escape_string () expects that my code in 2 parameters, 1

is

  & Lt; Php require_once ("include / session.php"); Require_once ("connection / connection.php"); Require_once ("include / functions.php"); ? & Gt; & Lt ;? Php $ username = $ _POST ['username']; $ Password = $ _POST ['password']; // $ hashed_password = md5 ($ password); ? & Gt; & Lt ;! - Get the user name password and authenticate whether the database is the same - & gt; & Lt ;? Php $ username = stripslashes ($ username); $ Password = strip slash ($ password); $ Username = mysqli_real_escape_string ($ username); $ Password = mysqli_real_escape_string ($ password); ? & Gt; & Lt ;? Php $ query = "SELECT * login WHERE user name = '{$ username}' and password = '{$ password}' and status = 1"; $ Result = mysql_query ($ query); $ Count = mysql_num_rows ($ result); If ($ count == 1) {// session $ result_fetch = mysql_fetch_array (for $ results); $ _SESSION ['user_id'] = $ results_fet ['id']; $ _SESSION ['user_name'] = $ results_fet ['username']; Session_register ("user name"); Session_register ("password"); Header ("Location: Dashboard .php"); Go out; } Else {echo "The username or password is incorrect."; }? & Gt; & Lt ;? Php // 5 Close connection if (isset ($ connection)) {mysql_close ($ connection); }? & Gt;    

> mysqli_real_escape_string requires two arguments :

Syntax:

  mysqli_real_escape_string ($ connection, $ escstesting);   

You seem to need to give this connection variable mysqli_connect ("host", "my_user", "my_password" "My_db");

You should

An alternative way is to use a database object so that you can not pass in the connection details each time.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -