FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


connection to database





alalex
i have a problem connecting to mysql database:
i read in some places that there are two ways, mysqli and mysql... and now im really confused...
could someone write me a connection code to a database, only that..
is it something like this:
Code:
 $connection = mysql.connect('username','pass','database name');

Sad
wumingsden
alalex wrote:
i have a problem connecting to mysql database:
i read in some places that there are two ways, mysqli and mysql... and now im really confused...
could someone write me a connection code to a database, only that..
is it something like this:
Code:
 $connection = mysql.connect('username','pass','database name');

Sad


Code:

// Database Information
$host="localhost";
$username="alalex"; // Your mySQL username
$password="Password Here"; // Your mySQL password
$db_name="alalex_database-name"; // Your database name

// The Actual Connection
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
alalex
ok thanks!! Very Happy
manum
to connect

mysql_connect($server,$username,$password);

to select a database

mysql_select_db(dbname);
seawolfxp
mysqli is better than mysql
Bejeweledhorses
this is realative to the topic


when i try to connect to the mysql databse, it always spits out something like this:


Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/share/php') in /www/freewebsitespace.net/j/e/w/jewelhorse/htdocs/db_connect.php on line 5


whats that mean?
ncwdavid
Bejeweledhorses wrote:
this is realative to the topic


when i try to connect to the mysql databse, it always spits out something like this:


Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/share/php') in /www/freewebsitespace.net/j/e/w/jewelhorse/htdocs/db_connect.php on line 5


whats that mean?


I think it means that it could not open your db.php file which container the info to connect to the database. try:
Code:

require()
//or
include()

and make sure the path to the file is correct and the permission.
catscratches
Don't forget to put your files inte the "public_html" folder
Related topics
script backup database
Implementing your database access in PHP as a layer.
Database Problem
Critical Database Error (Or something else)
PHP Tutorial: Making a Database Connection Page
[RESOLVED] 'localhost' database connection error!
MySQL connection
Get links from a database
connection JSP ms access
Problem connecting to MySQL database with PHP [RESOLVED]
Database connection class!
Database connection problems
Getting database connection error while installing wordpress
Database connection error (2): Could not connect to MySQL.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.