Jump to content
  • 0
Takuyakii

OLD themes php to new php

Question

Good day rA,

 

can someone help me to fix this error about query? i already googled some and fix the other error but this error, i can't fix it
 

MYSQLI_FETCH_ARRAY() EXPECT PARAMETER 1 to be MYSQLI_Result object given

 

below is my code 

<?php if (!defined('FLUX_ROOT')) exit; ?>
<?php
		
//SQL Connection
function Connection()
{
$db_host="127.0.0.1"; //insert the IP Address of your website
$db_name="rathena"; //insert your database name insid the 2 double quotesS
$username="zxc"; //insert the username of your phpmyadmin (SQL username)
$password="zxc"; //insert the password of your phpmyadmin (SQL password)
$conn = mysqli_connect($db_host,$username,$password);


    if (!$conn) {
        echo "Connection failed!";

        return false;
    }

    mysqli_select_db($conn, $db_name);

    return $conn;
}

$conn = Connection();

if ($conn)
{
    $hpsql = mysqli_query($conn, "SELECT * FROM cp_onlinepeak ORDER BY users DESC LIMIT 1");
    $hprow = mysqli_fetch_array($conn,$hpsql);

    
    echo $hprow['users'];
}

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
3 hours ago, Takuyakii said:

Good day rA,

 

can someone help me to fix this error about query? i already googled some and fix the other error but this error, i can't fix it
 

MYSQLI_FETCH_ARRAY() EXPECT PARAMETER 1 to be MYSQLI_Result object given

 

below is my code 

<?php if (!defined('FLUX_ROOT')) exit; ?>
<?php
		
//SQL Connection
function Connection()
{
$db_host="127.0.0.1"; //insert the IP Address of your website
$db_name="rathena"; //insert your database name insid the 2 double quotesS
$username="zxc"; //insert the username of your phpmyadmin (SQL username)
$password="zxc"; //insert the password of your phpmyadmin (SQL password)
$conn = mysqli_connect($db_host,$username,$password);


    if (!$conn) {
        echo "Connection failed!";

        return false;
    }

    mysqli_select_db($conn, $db_name);

    return $conn;
}

$conn = Connection();

if ($conn)
{
    $hpsql = mysqli_query($conn, "SELECT * FROM cp_onlinepeak ORDER BY users DESC LIMIT 1");
    $hprow = mysqli_fetch_array($conn,$hpsql);

    
    echo $hprow['users'];
}

 

Solved. please close this threads thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.