Mysql_result per PHP 7

nicemotion

Nuovo Utente
6 Feb 2010
17
1
3
Salve,
ho questo script di autorizzazione che sto convertendo in php 7


PHP:
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=mysqli_real_escape_string($tao_conn, $_POST['username']);
  $password=mysqli_real_escape_string(sha1($tao_conn, $_POST['password']));
  $MM_fldUserAuthorization = "AuthLev";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "loginSorry.php";
  $MM_redirecttoReferrer = false;
  mysqli_select_db($tao_conn, $database_tao_conn);
$LoginRS__query=sprintf("SELECT username, password, AuthLev FROM adminauth WHERE username=%s AND password=%s",
  GetSQLValueString($tao_conn,$loginUsername, "text"), GetSQLValueString($tao_conn,$password, "text"));
  
  $LoginRS = mysqli_query($tao_conn,$LoginRS__query) or die(mysqli_error($tao_conn));
  $loginFoundUser = mysqli_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysqli_result($LoginRS,0,'AuthLev');
    
    if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;         

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }

Ho riscritto " $loginStrGroup = mysqli_result($LoginRS,0,'AuthLev'); " come segue ma non mi funziona:

PHP:
$field = AuthLev ;

mysql_data_seek($LoginRS,0);
if( !empty($field) ) {
  while($finfo = mysqli_fetch_field( $LoginRS )) {
    if( $field == $finfo->name ) {
      $f = mysqli_fetch_assoc( $LoginRS );
      $loginStrGroup  = $f[ $field ];
    }
  }
} else {
  $f = mysqli_fetch_array( $LoginRS );
  $loginStrGroup  = $f[0];
}

any help ?
 
PHP:
function mysqli_result($result,$row=0,$field=0)
{

    $numrows = $result->num_rows;
   
    if ($numrows && $row <= ($numrows-1) && $row >=0){
        $result->data_seek(0);
        $result->data_seek($row);
        $resrow = (is_numeric($field)) ? mysqli_fetch_row($result) : mysqli_fetch_assoc($result);
       
        if (isset($resrow[$field])){return $resrow;}
    }
    return false;
}
Limite del codice non effetto esplicitamente la conversione in int e non prevedo la possibilità di chiamare tabella.colonna.
In php 7 sono state rimosse le funzioni mysql usa mysqli.
 
Ultima modifica:

Discussioni simili