Jump to content

Recommended Posts

Why doesn't this work? I get

Fatal error: Call to a member function query() on a non-object in /home/xxxxx/xxxxxxxxxxx/xxxxxxxxxxxx.com/includes/class.user.php on line 27

 

function checkLogin($username, $password) {

$sql = new mysqlQuery();

$sql->mysqlQuery();

$sql = "select * from users where username='$username' and password='$password' LIMIT 1";

$results = $sql->query($sql) ? "true" : "false";

 

if($results)

{

$array = $sql->fetch_array($sql->link_id, $sql);

$this->username = $username;

$this->password = $password;

$_SESSION['username'] = $username;

$_SESSION['password'] = $password;

}

}

 

I didn't include sql connection and a few other methods since they aren't needed.

<?php

class mysqlQuery {

 

# Global Cvars

# Database Information

var $link_id  = 0;

var $query_id = 0;

var $affected_rows = 0;

# - Error Information

var $error = "";

var $errno = 0;

# End Global Cvars

 

#############################

# Opens the connection.

# Returns results id.

function query($query_string) {

// do query

$this->query_id = @mysql_query($query_string,$this->link_id);

 

//if screwed up

if (!$this->query_id)

$this->messanger_handler("Mysql Error");

return $this->affected_rows = @mysql_affected_rows();

}

 

}

Link to comment
https://forums.phpfreaks.com/topic/73731-function-call-help/
Share on other sites

function checkLogin($username, $password) {

      $sql = new mysqlQuery();

      $sql->mysqlQuery();

      $sql = "select * from users where username='$username' and password='$password' LIMIT 1";

      $results = $sql->query($sql) ? "true" : "false";

     

 

that part of your code

no include for that class note its inside  the function

$sql->mysqlQuery(); <--where is the function mysqlQuery

Link to comment
https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372035
Share on other sites

There is the include require_once("class.query.php"); is it. Its called mysqlQuery.

mysqlQuery is the constructor being called. It connects you to the database. It has my sql info in there ct.. It works because I can login using that entire class then it trips out and pulls that when getting there info.

Link to comment
https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372037
Share on other sites

i think i  got it lol

    $sql = new mysqlQuery();

      $sql->mysqlQuery();

      $sql = "select * from users where username='$username' and password='$password' LIMIT 1";

    $results = $sql->query($sql) ? "true" : "false"; <--ERROR FOR SURE

you over right the value of $sql with that query

first you define $sql  as object

then you do this $sql = "select * etc....

Link to comment
https://forums.phpfreaks.com/topic/73731-function-call-help/#findComment-372038
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.