8 Replies - 601 Views - Last Post: 17 March 2009 - 04:05 PM Rate Topic: -----

#1 Justice92  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 30-September 08

IF problem

Posted 16 March 2009 - 02:02 PM

im having some problems seeing if the users account is activated, this will be put in the file to check there login info before moving on. but it wont read it even if the database entry is 1. it will still still show the login error.

the querys are running fine i dont know why it wont work?

Check code:
$ck=$db->query("SELECT activated FROM users WHERE login_name='{$_POST['username']}'");
if ($ck['activated']!="1")
{
$_SESSION['error'] = "Error: Account not activated, Check your inbox!";
header("Location: login.php");
exit;
}


Database function code:
  function query($query)
  {
	$this->last_query=$query;
	$this->num_queries++;
	$this->result=mysql_query($this->last_query, $this->connection_id) or $this->query_error();
	return $this->result;
  }



Is This A Good Question/Topic? 0
  • +

Replies To: IF problem

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: IF problem

Posted 16 March 2009 - 02:22 PM

How about
if ($ck['activated']!= 1)
??
Was This Post Helpful? 0
  • +
  • -

#3 Justice92  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 30-September 08

Re: IF problem

Posted 16 March 2009 - 02:48 PM

nope still nothing, ive been trying to do it most the day
Was This Post Helpful? 0
  • +
  • -

#4 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: IF problem

Posted 16 March 2009 - 04:17 PM

$result = $db->query("SELECT activated FROM users WHERE login_name='{$_POST['username']}'");
$ck = mysql_fetch_assoc($result);
if ($ck['activated'] != 1)
{
$_SESSION['error'] = "Error: Account not activated, Check your inbox!";
header("Location: login.php");
exit;
}


You were trying to call info out of the result resource as an array. You have to actually fetch the data first.

This post has been edited by Valek: 16 March 2009 - 04:17 PM

Was This Post Helpful? 1

#5 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,604
  • Joined: 20-January 09

Re: IF problem

Posted 16 March 2009 - 10:35 PM

Quote

->

What the crap does this mean!!!!

--

Greg
Was This Post Helpful? 0
  • +
  • -

#6 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: IF problem

Posted 17 March 2009 - 12:23 AM

It's used in object oriented programming. Syntax is $object->method() or $object->variable. In this case, $db is a database object (the OP is using a database class and has instantiated it in $db), and query is a method in that class.
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: IF problem

Posted 17 March 2009 - 05:10 AM

Good eye, Valek!
Was This Post Helpful? 0
  • +
  • -

#8 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,604
  • Joined: 20-January 09

Re: IF problem

Posted 17 March 2009 - 09:09 AM

ok so - he has a class and is calling function from within that class? Is that correct. Because I have begun creating classes, and I am liking it - it is beginning to remind me of AS3 in a way. I usually build multiple AS script files that connect to one movie that I call multiple elements from. Very neat - thanks.

--

Greg
Was This Post Helpful? 0
  • +
  • -

#9 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: IF problem

Posted 17 March 2009 - 04:05 PM

View Postgregwhitworth, on 17 Mar, 2009 - 11:09 AM, said:

ok so - he has a class and is calling function from within that class? Is that correct.


Precisely.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1