Hello,
I have a number of functions on a legacy php database website that have versions of mysql_result and I, of course, need to convert them to mysqli.
$result = mysqli_query($sql) or die(mysqli_connect_error());
[b]if (mysql_result($result, 0, "test" == 1)) {[/b]
return true;
} else {
return false;
}
}
and
function get_access_level() {
$sql = sprintf("SELECT access_level FROM %s WHERE login = '%s' AND active = 'y'", $this->table_name, $this->user);
if (!$result = mysqli_query($sql)) {
$this->the_msg = $this->messages(14);
} else {
[b]$this->access_level = mysql_result($result, 0, "access_level");[/b]
}
}
and
function send_confirmation($id) {
$sql = sprintf("SELECT email FROM %s WHERE id = %d", $this->table_name, $id);
[b]$user_email = mysql_result(mysqli_query($sql), 0, "email");[/b]
if ($this->send_mail($user_email, 37)) {
return true;
} else {
return false;
}
}
$forgot_sql = sprintf("SELECT id, pw FROM %s WHERE email = '%s'", $this->table_name, $this->user_email);
if ($forgot_result = mysqli_query($forgot_sql)) {
$this->id = mysql_result($forgot_result, 0, "id");
$this->user_pw = mysql_result($forgot_result, 0, "pw");
if ($this->send_mail($this->user_email, 35)) {
$this->the_msg = $this->messages(23);
[/code]
And there are a few more like those above. If I can figure out the how and why of the conversion I should be able to fix the rest of this code. I don’t get to do enough of this stuff to get a hard grasp of the syntax, so any help you can give is greatly appreciated.
Thanks!