php - Trying to convert code from MySQL to MySQLi -


this question has answer here:

recently started use older script located here: http://tutorial.ninja/tutorials/web+development/php+-+user+system/58/user+system+%28part+1%29/page-2.html

i've been trying edit configuration mysqli rather mysql i'm struggling. changed of this:

$conn = mysql_connect("localhost","user","password");  // connect local mysql database username , password mysql_select_db("dbname") or die(mysql_error()); //select database use  // query database account details if exist , store them in $logged variable $logged = mysql_fetch_array(mysql_query("select * `members` `id` = '".$_session['id']."' , `password` = '".$_session['password']."'"));  

to this:

$conn = mysqli_connect("localhost","root","root", "viozaki");  // connect local mysql database username , password    // query database account details if exist , store them in $logged variable    $logged = mysqli_query("select * users username='".$_session['username']."' , password = '".$_session['password']."'"); $logged = mysqli_fetch_array($logged); 

most of stuff googled. learned mysql connect can done in 1 including database name rather having select_db. have no issue that, however, next line confusing. no matter change to, these errors:

warning: mysqli_query() expects @ least 2 parameters, 1 given in config.php  warning: mysqli_fetch_array() expects parameter 1 mysqli_result, null given in config.php 

why this? thought adjustments changed work it, seems can't rid of errors. weird.

simple: need pass db connection query

$logged = mysqli_query($conn, "select ... 

read manual:

i noticed you're using sessions, make sure you've started it.

session_start(); must reside inside files using sessions, should not included already.

i noticed may storing passwords in plain text. if case, highly discouraged.

i recommend use crypt_blowfish or php 5.5's password_hash() function. php < 5.5 use password_hash() compatibility pack.

  • plus, storing passwords in sessions not idea , fall victim sessions hijacking.

read on subject:


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -