DamienRoche Posted December 12, 2008 Share Posted December 12, 2008 Hey peeps, not been around here for a long time - and it shows on me, I've completely forgot a whole bunch of stuff....one thing must be basic syntax etc. because I can't even connect to a db using a very simple class and function. Here it is: <?php class.php class db99{ function con($hst99, $user99, $pass99){ mysql_connect($hst99, $user99, $pass99) or die("Unable to connect to database"); } ?> and the index.php: <?php include('class.php'); $db99 = 'localhost'; $user99 = 'test'; $pass99 = 'whatever'; $db99 = new db99; $db99->con($hst99, $user99, $pass99); ?> The error I am getting when I access index.php is that test user cannot connect using password:YES... If I remember correctly, that's when the password hasn't been declared. Yet it's passing over the user 'test' .. appreciate any insight into this. Thanks. Damien. Link to comment https://forums.phpfreaks.com/topic/136611-solved-little-help-connecting-to-db-using-class/ Share on other sites More sharing options...
phpSensei Posted December 12, 2008 Share Posted December 12, 2008 try <?php include('class.php'); $hst99= 'localhost'; $user99 = 'test'; $pass99 = 'whatever'; $db99 = new db99; $db99->con($hst99, $user99, $pass99); ?> Link to comment https://forums.phpfreaks.com/topic/136611-solved-little-help-connecting-to-db-using-class/#findComment-713319 Share on other sites More sharing options...
DamienRoche Posted December 12, 2008 Author Share Posted December 12, 2008 Sorry, that would be $hst99 instead of two $db99. I wrote that part out from scratch here....typo. I've sussed it any way - I should have included a prefix to test = user_test Thanks for your time any way. Damien. Link to comment https://forums.phpfreaks.com/topic/136611-solved-little-help-connecting-to-db-using-class/#findComment-713334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.