0

Hello,

Worked on PDO everything as far as i see is correct why i am getting an error

) Fatal error: Call to undefined method mysqli::insert_id()

$result = "INSERT INTO users(unique_id, firstname, lastname, email, username, encrypted_password, salt, created_at) VALUES('$uuid', '$fname', '$lname', '$email', '$uname', '$encrypted_password', '$salt', NOW())";
        $connection->query($result);
       // check for successful store
        if ($result) {
            // get user details 
            $uid = $connection->insert_id(); // last inserted id
            $result1 = "SELECT * FROM users WHERE uid = $uid";
            //$connection->query($result1);
            // return user details
            return $connection->fetch_array($result1);
        } else {
            return false;
        }
5
Contributors
6
Replies
26
Views
2 Years
Discussion Span
Last Post by Gideon_1
0
Fatal error: Call to undefined method mysqli::fetch_array()

Now this error camed up though

1

You say your are using PDO, but your error messages (and code) show you are using MySQLi. You cannot mix them.

2

Let's see...

if ($result) {
        // get user details 
        $uid = $connection->insert_id(); // last inserted id
        $result1 = "SELECT * FROM users WHERE uid = $uid";
        //$connection->query($result1);
        // return user details
        return $connection->fetch_array($result1);

$result1 is a string. You are passing a string to a fetch_array() method. Shouldn't it be a resource, i.e. from a query?

0

Yh, your question does not justify the error you are having right now. You said PDO but the error is in mysqli. Also you are not querying the database for the $result1 instead fetching the array of a string.

Can you show the codes for the connection.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.