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;
        }

Change this

$uid = $connection->insert_id();

To

$uid = $connection->insert_id;

Check this Click Here

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

Now this error camed up though

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

Member Avatar
diafol

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?

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.