- Connecting to a mysql server, it's the most of time installed in the same server where php is, so we uselocalhost as address of mysql server.mysql_connect("localhost", "username", "password") or die(mysql_error());
echo "Connected to MySQL Server";
Some times, when you are running a server in your own computer and not a hosting service provider's, you can connect with just indicating username "root" with no password, and some times is no need to enter an username. It's all depend on your current mysql configuration. - After you are connected to a mysql server, you need then to connect to a mysql database:mysql_select_db("database-name") or die(mysql_error());
echo "Connected to Mysql Database";
Showing posts with label Mysql. Show all posts
Showing posts with label Mysql. Show all posts
1 comments
Connect to Mysql Database
Connecting to the mysql database is done in two steps:
About Mysql Database
So you want to know what is mysql ? Or already now it and want to learn how to use it with php ? In all cases we are here to help you !
Mysql is useful when you want to store data, infos... Yes you can save your data in a text file, but will not be easy to read details, to search, or any other task...
For example, let's say you want to store details of users of your website, every user will have an username, password, and email , you can so create a database, with a table "users", and that table has 3 columns: username; password; email, and each user occupies one line. It's exactly like Excel documents...
In that example, you can store data in a text file, each user per line, his details seperated with ";" , but that will make a big file if you have many users, so script will be slow in reading and writing, and the most important thing: searching.
Mysql is known as a fast database, and very smart one.
You can use many tables in the same mysql database, and with relations between them, which make it the best database.
Mysql is used with php, but has its own language, so php functions will send mysql scripts to mysql server, then the server do the tasks, and send back results to php where you can manipulate them.
You can for example read all details from a mysql table, or insert a new entry, update one, or delete another, or search in the table and get the matching entries, or sort data, or create a new table ...
We will see step by step how to do all that,
Will see you again, bye !
Mysql is useful when you want to store data, infos... Yes you can save your data in a text file, but will not be easy to read details, to search, or any other task...
For example, let's say you want to store details of users of your website, every user will have an username, password, and email , you can so create a database, with a table "users", and that table has 3 columns: username; password; email, and each user occupies one line. It's exactly like Excel documents...
In that example, you can store data in a text file, each user per line, his details seperated with ";" , but that will make a big file if you have many users, so script will be slow in reading and writing, and the most important thing: searching.
Mysql is known as a fast database, and very smart one.
You can use many tables in the same mysql database, and with relations between them, which make it the best database.
Mysql is used with php, but has its own language, so php functions will send mysql scripts to mysql server, then the server do the tasks, and send back results to php where you can manipulate them.
You can for example read all details from a mysql table, or insert a new entry, update one, or delete another, or search in the table and get the matching entries, or sort data, or create a new table ...
We will see step by step how to do all that,
Will see you again, bye !
Subscribe to:
Comments (Atom)
Search With Google
Categories
- 1-General (3)
- 2-Getting started (4)
- 3-Strings (10)
- 4-Server config (1)
- 5-Best scripts (7)
- email (4)
- files (6)
- Forms (3)
- If statements (3)
- Loop statements (2)
- Mysql (2)
- Server variables (3)
- Sessions (1)
- Tutorials-planet.com (1)
- web hosting (1)
- You need a programmer ? (1)





