Jump to content

Recommended Posts

I'm trying to recreate the code from PHP, mysql, javascript, CSS and HTML from O'reily, but i can't make it work

 

Here's the code I added:

       

        $query = "select * from classics";
        $result = $connection->query($query);
        if (!$result) die ("Database access failed: " . $connection->error);
        $rows = $result->num_rows;
        for ($j=0; $j < $rows; ++$j)
        {
            $result->data_seek($j);
            $row = $result->fetch_array(MYSQLI_NUM);
        echo <<<_END
        <pre>
        Author        $rows[0]
        Title            $rows[1]
        Category    $rows[2]
        Year            $rows[3]
        ISBN           $rows[4]
        </pre>    
        _END;
        }
 

Here's the error i receive:

Notice: Trying to access array offset on value of type int in /var/www/html/test/mysqlitest.php on line 53

I didn't put all the code because everything else works well, i can connect to mysql and add stuff, but i can retrieve stuff using fetch_array['author'] but fetch_array(MYSQLI_NUM) doesn't work.

I've tried things from the web but I've only been doing php for a week so my knowledge is quite limited.

Thank you for your time.

Link to comment
https://forums.phpfreaks.com/topic/311902-mysqli_num-doest-work/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.