GetDotted Domains

Viewing Thread:
"PHP Error (Array)"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Tue 06/01/04 at 17:30
Regular
"previously phuzzy."
Posts: 3,487
Have a look at this PHP. It takes in data from 2 forms, and later on uses a switch statement to allow or deny access to a page.

$query = "SELECT memberPass FROM member WHERE memberName = '$userentry'";
$result = mysql_query($query)
or die("SYerror 03 : Could Not Execute Query");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
extract($row);
switch ($memberPass)

The problem is, when a log in fails, a warning appears :

Warning: extract(): First argument should be an array in...

Need to get rid of it, somehow. Any ideas?
Tue 06/01/04 at 22:19
Regular
"Devil in disguise"
Posts: 3,151
phuzzy wrote:
> What is the is_array thing? What does it do exactly?

Its just a built in php function that checks whether the variable you pass to it is an array or not. Check http://www.php.net/is_array if you want to know more.
Tue 06/01/04 at 18:07
Regular
"previously phuzzy."
Posts: 3,487
Thanks matey :D Works a dream.

What is the is_array thing? What does it do exactly?
Tue 06/01/04 at 17:48
Regular
"Devil in disguise"
Posts: 3,151
Your problem is when the login fails, then your mysql result contains 0 rows, so when you call mysql_fetch_array it returns false to $row rather than an array which then gets passed to extract which expects an array as its first argument, hence the error.
Several solutions I guess, something like:

if (is_array($row)) {
extract($row);
} else {
// if row isn't an array then init the vars to something so they make
// some sense to later code.
$memberPass="";
}

That should fix your error. Its not the best solution, but it works hopefully.
Tue 06/01/04 at 17:30
Regular
"previously phuzzy."
Posts: 3,487
Have a look at this PHP. It takes in data from 2 forms, and later on uses a switch statement to allow or deny access to a page.

$query = "SELECT memberPass FROM member WHERE memberName = '$userentry'";
$result = mysql_query($query)
or die("SYerror 03 : Could Not Execute Query");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
extract($row);
switch ($memberPass)

The problem is, when a log in fails, a warning appears :

Warning: extract(): First argument should be an array in...

Need to get rid of it, somehow. Any ideas?

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thanks!
Thank you for dealing with this so promptly it's nice having a service provider that offers a good service, rare to find nowadays.
Second to none...
So far the services you provide are second to none. Keep up the good work.
Andy

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.