Connecting to the database

rubencit

New Member
Messages
28
Reaction score
1
Points
0
In this example we create a table named test with three fields: an ID field, which will serve to uniquely identify a row with the value of that field, another field with the name of a person and finally a field with the name of the person .

To create the table you can use the MySQL administration tool on your web server or you can write a text file with the contents of the corresponding SQL statement and then tell the database engine that runs with the following statement:
mysql-u root base_datos <prueba.sql

prueba.sql
CREATE TABLE test (
ID_Prueba int (11) DEFAULT '0 'NOT NULL auto_increment,
Name varchar (100)
Surname varchar (100)
PRIMARY KEY (ID_Prueba)
UNIQUE ID_Prueba (ID_Prueba)
);


<?php
function Conectarse()
{
if (!($link=mysql_connect("localhost","usuario","Password")))
{
echo "Error connecting to database.";
exit();
}
if (!mysql_select_db("base_datos",$link))
{
echo "Error selecting the database.";
exit();
}
return $link;
}

$link=Conectarse();
echo "Connecting to the database obtained.<br>";

mysql_close($link);
?>
 

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
To create your database, you must use cPanel --> MySQL Database Wizard.

Replace usuario (username) in your script to the database username (something like cpanelnamehere_usernamehere) and database password. Replace base_datos with the database name.
 

clmirand

New Member
Messages
5
Reaction score
0
Points
0
Hi there,
I have a previous inquiry about uploading my database.
However, by reading some of the forums, I realized that my problem could be my PHP admin.
It is not opening for me. All it says is Please be patient, you will be redirected in a moment....
Please help :(

Thank you.
 
Top