Topic: [Tutorial] How to connect to MYSQL Database

It is very simple to connect to a mysql database:

just use this simple code:

<?php
mysql_connect("localhost", "username", "password") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("database") or die(mysql_error());
echo "Connected to Database";
?>

Thumbs up

Re: [Tutorial] How to connect to MYSQL Database

And for something more usefull, to use it as a function so you can call it when you need it.

function db_connect() {
$connect = mysql_connect("localhost", "username", "password", );
if(!mysql_select_db("database"))
   {
      return false;
   } else {
      return $connect;
   }
}

Thumbs up

Re: [Tutorial] How to connect to MYSQL Database

Hello friends,

please can you provide idiot-proof step by step information about how set up a MySQL database on my pc which is also accessible from afar?

This could also work for others as a tutorial(and probably broaden our community).

I already have problem downloading the proper files from sunmicro nor do I know what to do with them as they are no exe or batch files.

Last edited by Reginald (October 2, 2010 00:34)

Thumbs up

Re: [Tutorial] How to connect to MYSQL Database

Very useful for me.. Thanks for sharing this function..

Thumbs up

Re: [Tutorial] How to connect to MYSQL Database

Nice full post and help for me.

How to connect to MySql Database from Servlet?






-----------


STC Technologies|Reputation Management

Last edited by paddysmith (March 14, 2012 03:34)

Thumbs up

6

Re: [Tutorial] How to connect to MYSQL Database

$connect = mysql_connect(

Thumbs up

Re: [Tutorial] How to connect to MYSQL Database

Many times,michael kors hamilton are
lightweight, durable and unique. michael kors handbags on sale are not only stylish but also functional.michael kors handbags come in a wide rang of
colors like sky blue, bubblegum pink, navy, pewter, apple green and so on. Replica Scarf handbags come in various styles and sizes to meet any needs.

Thumbs up