Jump to content

What am i doing wrong?


rizmah

Recommended Posts

where is your class with fetchColumn() method? 

In the functions.php \/

<?php
class user
{
	function isAdmin($odb)
	{
		$SQL = $odb -> prepare("SELECT `rank` FROM `users` WHERE `ID` = :id");
		$SQL -> execute(array(':id' => $_SESSION['ID']));
		$rank = $SQL -> fetchColumn(0);
		if ($rank == 2)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	function isReseller($odb)
	{
		$SQL = $odb -> prepare("SELECT `rank` FROM `users` WHERE `ID` = :id");
		$SQL -> execute(array(':id' => $_SESSION['ID']));
		$rank = $SQL -> fetchColumn(0);
		if ($rank == 1)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	function LoggedIn()
	{
		@session_start();
		if (isset($_SESSION['username'], $_SESSION['ID']))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	function hasMembership($odb)
	{
		$SQL = $odb -> prepare("SELECT `expire` FROM `users` WHERE `ID` = :id");
		$SQL -> execute(array(':id' => $_SESSION['ID']));
		$expire = $SQL -> fetchColumn(0);
		if (time() < $expire)
		{
			return true;
		}
		else
		{
			$SQLupdate = $odb -> prepare("UPDATE `users` SET `membership` = 0 WHERE `ID` = :id");
			$SQLupdate -> execute(array(':id' => $_SESSION['ID']));
			return false;
		}
	}
	function notBanned($odb)
	{
		$SQL = $odb -> prepare("SELECT `status` FROM `users` WHERE `ID` = :id");
		$SQL -> execute(array(':id' => $_SESSION['ID']));
		$result = $SQL -> fetchColumn(0);
		if ($result == 0)
		{
			return true;
		}
		else
		{
			session_destroy();
			return false;
		}
	}
}
class stats
{
	function totalUsers($odb)
	{
		$SQL = $odb -> query("SELECT COUNT(*) FROM `users`");
		return $SQL->fetchColumn(0);
	}
	function totalBoots($odb)
	{
		$SQL = $odb -> query("SELECT COUNT(*) FROM `logs`");
		return $SQL->fetchColumn(0);
	}
	function runningBoots($odb)
	{
		$SQL = $odb -> query("SELECT COUNT(*) FROM `logs` WHERE `time` + `date` > UNIX_TIMESTAMP()");
		return $SQL->fetchColumn(0);
	}
	function totalnews($odb)
	{
		$SQL = $odb -> query("SELECT COUNT(*) FROM `news`");
		return $SQL->fetchColumn(0);
	}
function totaltickets($odb)
	{
		$SQL = $odb -> query("SELECT COUNT(*) FROM `tickets`");
		return $SQL->fetchColumn(0);
	}
	function totalBootsForUser($odb, $user)
	{
		$SQL = $odb -> prepare("SELECT COUNT(*) FROM `logs` WHERE `user` = :user");
		$SQL -> execute(array(":user" => $user));
		return $SQL->fetchColumn(0);
	}
	function totalusertickets($odb, $user)
	{
		$SQL = $odb -> prepare("SELECT COUNT(*) FROM `tickets` WHERE `username` = :user");
		$SQL -> execute(array(":user" => $user));
		return $SQL->fetchColumn(0);
	}
function usersforplan($odb, $plan)
	{
		$SQL = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `membership` = :membership");
		$SQL -> execute(array(":membership" => $plan));
		return $SQL->fetchColumn(0);
	}
}
?>
Link to comment
Share on other sites

I don't know maybe the file is included inside another included file, you have to tell me :)

 

There's an index.php in the main directory that im trying to get on to. That doesn't include anything on functions.php and there's another index.php in the includes folder that doesn't do anything I don't think and the code in there is just... haha i dunno why it said 'Derp', I didnt make this but I am editing it so I can just use the source.

<?php
echo "Derp";
?>
Link to comment
Share on other sites

 

Fatal error: Call to a member function query() on a non-object in

 

This error comes from mysqli library not from pdo. Can you explain this? Ah...I googled it comes from pdo as well. So then check if your database credentials are correct, inside db.php file.

Edited by jazzman1
Link to comment
Share on other sites

This error comes from mysqli library not from pdo. Can you explain this?

 

I didn't use the original SQL file that's why. I used a different one that didn't belong to it. I can't get the original one that belonged to the source I am using. I need to make an SQL then :/ If I learn how to do it...

Link to comment
Share on other sites

Ok, got it. Go to db.php and add the line after the $obd object. Run the script again do a "view source" and post the new error.  

<?php
	if(strpos(strtolower($_SERVER['SCRIPT_NAME']),strtolower(basename(__FILE__)))){
		die('Error!');
	}
	define('DB_HOST', '*REMOVED*');
	define('DB_NAME', '*REMOVED*');
	define('DB_USERNAME', '*REMOVED*');
	define('DB_PASSWORD', '*REMOVED*');
	$odb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWORD);
        $odb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
Link to comment
Share on other sites

 

Ok, got it. Go to db.php and add the line after the $obd object. Run the script again do a "view source" and post the new error.  

<?php
	if(strpos(strtolower($_SERVER['SCRIPT_NAME']),strtolower(basename(__FILE__)))){
		die('Error!');
	}
	define('DB_HOST', '*REMOVED*');
	define('DB_NAME', '*REMOVED*');
	define('DB_USERNAME', '*REMOVED*');
	define('DB_PASSWORD', '*REMOVED*');
	$odb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWORD);
        $odb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>

Result \/


Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'REMOVED_test.SiteConfig' doesn't exist' in /home/REMOVED/public_html/TZ/v3/header.php:2
Stack trace:
#0 /home/REMOVED/public_html/TZ/v3/header.php(2): PDO->query('SELECT `Tab` FR...')
#1 /home/REMOVED/public_html/TZ/v3/index.php(21): require_once('/home/REMOVED/...')
#2 {main}
  thrown in /home/REMOVED/public_html/TZ/v3/header.php on line 2

Link to comment
Share on other sites

Obviously, you haven't done yet :) You need to fix the issue if you want to go further.

 

Do you know how to create an SQL file..? At this minute I don't know how to fix anything on there haha, I might as well delete the whole thing and just stick with my current one.. www.rmzhcp.comyr.com < do you like it?

Link to comment
Share on other sites

The easiest way for you is to use some DB GUI tool like phpMyAdmin, not personally using but for beginners is good. Then, connect to mysql server, open up the database named - "REMOVED_test" and create a table - SiteConfig.

I'm already using phpmyadmin, just started to use it so ill look around to making it. What content should i put in this siteconfig?

Link to comment
Share on other sites

This is very interesting question :) You need to open a new thread I think :)

I have been given the original sql file so I have that now but a dude of Skype said that it all was originally run on XAMPP and im trying to run it off 000webhost. He said that's the problem.

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.