I'm having a problem with creating a database for my forms.
Moderator: General Moderators
I'm having a problem with creating a database for my forms.
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.

-
fastfingertips
- Forum Contributor
- Posts: 242
- Joined: Sun Dec 28, 2003 1:40 am
- Contact:
I'm sending you my database class, it has inside all details that you may need.
To build the object
When you want to send a script to your database server you will only have to write this:
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;
}
}
}
?>Code: Select all
<?php
$sqlpipe=new database();
?>Code: Select all
<?php
$result=mysql_query($sql,$sqlpipe->connect());
?>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?
<?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?