Jump to content

can someone help me please ?


bogdaniel

Recommended Posts

 /*
Create the mysql class_exists
*/

class mysql
{

	var $MYSQL_user = DBUSER;//MySQL username variable
	var $MYSQL_pass = DBPASS;//MySQL password variable
	var $MYSQL_host = DBHOST;//MySQL host variable - usually localhost
	var $MYSQL_db = DB;//MySQL database variable

	var $connect;
	var $get_db;

	function __construct(   ) {//PHP 5 Constructor

		$this->Connect(   );
	}

	function mysql(   ) {//PHP 4 constructor

		$this->Connect(   );

	}

	function Connect(   ) {//Create a function called Connect that is responsible for connecting to the mysql db

		$this->connect = mysql_connect($this->MYSQL_host, $this->MYSQL_user, $this->MYSQL_pass)or die(mysql_error(   ));
  			$this->get_db = mysql_select_db($this->MYSQL_db) or die(mysql_error().__LINE__.__FILE__);
	}//End function


	function __destruct(   ) {//Automatically closes the mysql connection
		mysql_close(   $this->connect   ); // here on line 43 i have an error

	}

/*
The queries
*/

	function GetUserLogin($username, $password) { //Create a new function that requires you define the vars $username and $password when initiating

		$query = "
		SELECT username, id, password FROM `users` 
		WHERE
		`username` = '". $username ."' 
		AND 
		`password` = '". $password ."' 
		AND
		`banned` = 'n' 
		LIMIT 1; 
		";//Create the MySQL query and make sure they arent banned
		return $query; //Return the query string
	}


	function GetUser(   $username   ) {//Create a function that gets a users info

		$query = "
		SELECT username, id, email FROM `users` 
		WHERE 
		`username` = '". $username ."' 
		LIMIT 1; 
		";//Create the MySQL query and make sure they arent banned

		return $query; //Return the query string
	}


	function RegisterUser(   $username, $password, $email, $ip   ) {//Create a new function that requires certain variables
		$query = "
		INSERT INTO `users`
		(`username`, `password`, `email`, `ip`, `level`)
		VALUES
		('". $username ."', '". $password ."', '". $email ."', '". $ip ."', '1');
		";//Create a MySQL query that inserts values into the database

		return $query; //Return the query string
	}


}//End class

 

 

 

Warning on line 43,

mysql_close(): supplied argument is not a valid MySQL-Link resource,

in C:\xampp\htdocs\ooptests\classes\mysql.php

 

can someone help me please ?

Link to comment
https://forums.phpfreaks.com/topic/112575-can-someone-help-me-please/
Share on other sites

it means whatever variable you have supplied in mysql_close(); doesn't exist, or is the wrong variable.

 

ACE

 

i know that... but can you help me fix it ? cuz i don't have any ideea why it does like that all the time i used the form of writing and this is the first time that give me and error :(

Because the destructor is called when php terminates due to the die() statement when your connection fails, your mysql_close() is using a non-existent link. You would need to test if $this->connect is TRUE and only execute the mysql_close() statement if it is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.