i am new to study web development..can anyone help me to how i can connect my website with the database..what are the requirements..very basic please.!!

Recommended Answers

All 7 Replies

What scripting language are you using?

which language is best to study in this trend... php and mysql..

What does your website support?

You need to choose the tools for the job. If you're using PHP and MySQL, you should look into either the MySQLi or PDO extensions for PHP. These will let PHP connect to your MySQL database.

can you explain how to connect website with datbase using PHP.......

Very easy,here's a detailed connection PHP & MySQL:

//$variables to use in the connection
$host = 'localhost'; //Most of the time it''s 'localhost' but may be different
$user = 'root'; //username
$pass = ''; //password
$db = 'daniweb';

//first you have to make the connection, if not made => mysql_error()
$connection = mysql_pconnect($host,$user,$password);

//select the datbase you want to use, if not found => mysql_error()
mysql_select_db($db,$connection) or die(mysql_error());

//now the sql part
$query = mysql_query("SELECT * FROM table");

//fetch results
$row = mysql_fetch_assoc($query);

//Count results (optional)
$row_num = mysql_num_rows($query);

That's it !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.