I'm having a problem with creating a database for my forms.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zimmer
Forum Commoner
Posts: 59
Joined: Fri Jan 09, 2004 8:22 pm

I'm having a problem with creating a database for my forms.

Post by zimmer »

click here << - I don't understand what is wrong with what I did at that site, if someone has the solution please post, help would be much appreciated.

:cry: :cry:
Fataqui
Forum Newbie
Posts: 10
Joined: Fri Jan 09, 2004 7:47 pm

Post by Fataqui »

Hi


Are you sure you are using the correct username and or password! The second error is caused by the first error ('mysql_connect()')!


F!
zimmer
Forum Commoner
Posts: 59
Joined: Fri Jan 09, 2004 8:22 pm

Post by zimmer »

I didn't use a password, I don't know what to do (sorry I'm new to php and I'm using the php bible)
Fataqui
Forum Newbie
Posts: 10
Joined: Fri Jan 09, 2004 7:47 pm

Post by Fataqui »

Hi


The database is setup with a password...

This is why you get this! -> (Using password: YES)


MySQL is telling you the error is that 'Access denied', it is also telling you that it is using a password!


What are you trying to run?


F!
zimmer
Forum Commoner
Posts: 59
Joined: Fri Jan 09, 2004 8:22 pm

Post by zimmer »

I'm trying to make a database to send all of my form information to.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

I'm sending you my database class, it has inside all details that you may need.

Code: Select all

<?php
$mysite['db_server']="localhost"; // This is usually loclhost
$mysite['db_name']=""; // Insert here the database name
$mysite['db_user']=""; // Insert the database user
$mysite['db_pass']=""; // Insert the user password

class database
{
    var $DatabaseLink;
    var $Connected;
    var $CloseConnection;    
    //This function will opena a database connection to the Mysql Server
    function connect()
    {
        global $mysite;
        if(is_null($this->DatabaseLink))
        {
            $this->DatabaseLink=mysql_connect($mysite['db_server'],$mysite['db_user'],$mysite['db_pass']);
            $this->Connected=mysql_select_db($mysite['db_name'],$this->DatabaseLink);
        }
        return $this->DatabaseLink;
    }
    function closeconnect()
    {
        global $mysite;
        if(!is_null($this->DatabaseLink))
        {
            $this->CloseConnection=mysql_close($this->DatabaseLink);
            $this->DatabaseLink= NULL;
        }
    }
}
?>
To build the object

Code: Select all

<?php
$sqlpipe=new database();
?>
When you want to send a script to your database server you will only have to write this:

Code: Select all

<?php
$result=mysql_query($sql,$sqlpipe->connect());

?>
zimmer
Forum Commoner
Posts: 59
Joined: Fri Jan 09, 2004 8:22 pm

Post by zimmer »

well, this is the code I'm using and it doesn't work:
<?php
$dbh=mysql_connect ("localhost", "zimmer_greeneggs", "<yes I entered the passowrd here>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("zimmer_xmb1");
?>

(the username is greeneggs (to the database)
the overall username is zimmer
the database's name is zimmer_xmb1


What am I doing wrong?
Post Reply