CaptainChainsaw Posted July 15, 2008 Share Posted July 15, 2008 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 Link to comment https://forums.phpfreaks.com/topic/114925-solved-sql-not-being-executed-problem-prob-yet-another-simple-one/ Share on other sites More sharing options...
next Posted July 15, 2008 Share Posted July 15, 2008 You need to connect to your DB and select Database first Link to comment https://forums.phpfreaks.com/topic/114925-solved-sql-not-being-executed-problem-prob-yet-another-simple-one/#findComment-591074 Share on other sites More sharing options...
trq Posted July 15, 2008 Share Posted July 15, 2008 register is a method not a property. $user->register(); Link to comment https://forums.phpfreaks.com/topic/114925-solved-sql-not-being-executed-problem-prob-yet-another-simple-one/#findComment-591076 Share on other sites More sharing options...
CaptainChainsaw Posted July 15, 2008 Author Share Posted July 15, 2008 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 Link to comment https://forums.phpfreaks.com/topic/114925-solved-sql-not-being-executed-problem-prob-yet-another-simple-one/#findComment-591094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.