Jump to content

[SOLVED] SQL not being executed problem (prob yet another simple one)


CaptainChainsaw

Recommended Posts

Hi all, I'm sure this is yet another simple one, I just can't see why my SQL isn't being executed.  Also the line echo "here"; isn't displaying anything either.  The values passed into the constructor are however echoable.

 

 

<?php
class user{
		private $_username='';
		private $_password='';
		private $_db='';

		public function __construct($username, $password, $db) {
			$this->_username=$username;
			$this->_password=$password;
			$this->_db=$db;
		}

		public function register(){
			echo "here";
			mysql_query("INSERT INTO users SET username='$this->_username', password='$this->_password'", $this->_db);
		}

}
?>	

 

 


$user=new user($_POST['username'], $_POST['password'], $db);
$user->register;



 

 

Any ideas?

 

 

Thanks again,

 

CC :)

next - hehe thank you, already had done that earlier in my code ;)

 

thorpe - thank you again, I think I've been programming perl too long!  I also noticed that the line:

 

mysql_query("INSERT INTO users SET username='$this->_username', password='$this->_password'", $this->_db);

 

 

should be:

 

mysql_query("INSERT INTO users SET username='$this->_username', password='$this->_password'", $this->_db->connect());

 

 

All works now.  Thank you very much for your help!

 

CC :)

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.