Jump to content

Please help with connect Funtion


soupy127

Recommended Posts

Hi just wandering if anybody could help me edit this connect file so that it works with Loccalhost, root and duffers as the name of the db?

 

function setupdb($dbuser,$pw,$dbase)

{

$this->dbuser=$dbuser;

$this->pw=$pw;

$this->dbase=$dbase;

$this->db = mysql_connect('localhost',$dbuser,$pw);

}

 

 

Everytime i edit it i get errors :(! could somebody help me please?

 

Link to comment
Share on other sites

function setupdb($dbuser,$pw,$dbase)
{
$this->dbuser=$dbuser;
$this->pw=$pw;
$this->dbase=$dbase;
$this->db = mysql_connect('localhost',$this->dbuser,$this->pw) or die(mysql_error());
mysql_select_db($this->dbase, $this->db) or die(mysql_error());
}

Link to comment
Share on other sites

Thanks for your help :)!! but wanted to know were to put localhost, root and duffers (which is the name of the database) do i have to remove the password variable as there is no password? i.e. tried this but got errors :(,

 

function setupdb($dbuser,$pw,$dbase)

{

$this->localhost=$dbuser;

$this->''=$pw;

$this->duffers=$dbase;

$this->db = mysql_connect('localhost',$dbuser,$pw);

}

 

thanks for your help!!

Link to comment
Share on other sites

Sorry im useless at this, is this what you where looking for? as when i change these values to localhost, root, duffers i get errors :(!

 

include "class.agolfhandicap.php";

$gh=new agolfhandicap();

 

// ######### Edit the next line to put your MySQL username, password, and database name. ########

$gh->setupdb('username','password','databasename');

 

 

thanks for the help again

Link to comment
Share on other sites

Thanks for the reply :)!

 

When i edit the funtion to look like this

 

$gh->setupdb('localhost','root','duffers');           

 

duffers being the name of the database.  I get these errors

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'localhost'@'localhost' (using password: YES) in C:\wamp\www\handicap system\class.agolfhandicap.php on line 65

 

Notice: Undefined index: user in C:\wamp\www\handicap system\agolfhandicap.php on line 19

 

Notice: Undefined index: delete in C:\wamp\www\handicap system\agolfhandicap.php on line 23

 

Notice: Undefined index: edit in C:\wamp\www\handicap system\agolfhandicap.php on line 27

 

Notice: Undefined variable: PHP_SELF in C:\wamp\www\handicap system\agolfhandicap.php on line 32

 

 

if i click the submit button i get even more errors :(!! please help if you can :)!!

thanks again.

Link to comment
Share on other sites

lol thanks, i replaced it with this

 

$gh->setupdb('root','','duffers');

 

and still getting the errors

 

Notice: Undefined index: user in C:\wamp\www\handicap system\agolfhandicap.php on line 19

 

Notice: Undefined index: delete in C:\wamp\www\handicap system\agolfhandicap.php on line 23

 

Notice: Undefined index: edit in C:\wamp\www\handicap system\agolfhandicap.php on line 27

 

Notice: Undefined variable: PHP_SELF in C:\wamp\www\handicap system\agolfhandicap.php on line 32

 

thanks again for your help :)!!

 

Link to comment
Share on other sites

soz that was the wrong class.file, as i have been trying to edit that one. here is the orignal, sorry again.

 

I think the script itself should be ok as I think a few people on this site have it working, just not working for me for some reason :S haha

 

i tried changing

 

if($_POST['user']){

$user=$_POST['user'];

 

to

 

if(!empty($_POST['user'])){

$user = empty($_POST['user']);

 

and the undefined error for user went away, should i do this for each of the variables? or is that coding wrong :(!

 

[attachment deleted by admin]

Link to comment
Share on other sites

soupy127, notices aren't really big errors. Your code will still work fine though. You should always check if a variable isset as thorpe pointed out.

 

It appears that this is solved. Are you still having complications?

 

FYI: $PHP_SELF is deprecated. Either use $_SERVER['PHP_SELF'] or omit it if you're submitting data to the same file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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