Jump to content

extract() expects parameter 1 to be array, Help please


Namtip

Recommended Posts

I'm a newbie :shy:. I've been stuck on this error message for 2 days:

I get this error message: extract() expects parameter 1 to be array, boolean given in C:\x\xampp\htdocs\user_personal.php on line 30

 

<?php
$query = 'SELECT
        about_me, job, hobbies, contact
    FROM
        site_user u JOIN
        site_user_profile p ON u.user_id = p.user_id
    WHERE
        username = "' . mysql_real_escape_string($_SESSION['username'], $db) . '"';
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_array($result);
extract($row);
mysql_free_result($result);
mysql_close($db);
?>

I think joining table is hard, I just want to create a profile that would be linked to a user name. Please be my friend and help me so I can have PHP phun time.

Link to comment
Share on other sites

The error means that your query matched zero rows (the WHERE clause was FALSE).

 

You should use mysql_num_rows() to find out if your query matched anything before you attempt to fetch and access the data.

 

As to why your query did not match anything, are you sure your $_SESSION variable contains what you expect? What do you get if you echo $query?

Link to comment
Share on other sites

Thanks guys you're pros. Ah, there isn't any data for the database to retrieve. Could this be why the error message comes up? What should I enter into my code if I want it to display nothing without an error message?

 

This is what it said when I echo'd the query

SELECT about_me, job, hobbies, contact FROM site_user u JOIN site_user_profile p ON u.user_id = p.user_id WHERE username = "Russell"

Link to comment
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.