Jump to content

[SOLVED] Little help connecting to db using class


DamienRoche

Recommended Posts

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.

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.

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.