mysql - Login doesn't work when changed to mysqli -


require_once("config.php"); if(isset($_post['go'])) { $np = $_post['nm']; $ps = $_post['pass']; $np = mysqli_real_escape_string($np); $ps = mysqli_real_escape_string($ps); $q = "select * `pilots` `name`='$np' , `pass`='$ps'"; $query = mysqli_query($q); if(mysqli_num_rows($query)) {     $_session['login'] = $np;     header("location:index.html"); } else     echo 'oi';     } 

this login after switched mysqli , doesn't work, connection if neede in config.php:

session_start(); error_reporting(false); $connection[0] = 'localhost'; $connection[1] = 'michael'; $connection[2] = '123123'; $connection[3] = 'aodpanel';  mysqli_real_connect($connection[0],$connection[1],$connection[2],$connection[3]); //mysql_connect($connection[0],$connection[1],$connection[2]) or die; //mysql_select_db($connection[3]); 

error_reporting(false); - this root of problem.

change

error_reporting(-1); 

and never let have other value.

the rest piece of cake: read error messages php throws , correct code accordingly

changing mysqli not adding "i" every function call. 2 main things mysqli 1 should know

  • every function call require connection resource provided explicitly
  • all data should go query via placeholder.

the latter nightmare mysqli, api not intended used is, building source higher level abstraction class.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -