CPanel - MySQL setup - File Manager

++++




CPanel - File Manager

Place this connect.php file in a directory that is upper than yur root directory. Click Home link on MySQL database and users screen and find a File manager icon.

File manager icon

Click File manager icon and you will see all your directories. The public_html directory is your root directory where all your html or php files are places. Select your home directory and click New Folder icon enter a name 'conn' and click Create Folder button.

Create folder

The folder will be created. Select the conn folder and click New File icon.

Create file

Enter connect.php for the file name and click Create New File button. The file is created.

edit file

A window opens and with the Disable Encoding Check button and Edit button. If you use latin characters for database users and name ignore Encoding check and click Edit button. Text editor opens. Type or copy and paste contents for connect.php file and save.

<?php

$hostname = "localhost";
$dbuser = "spillout_reg";
$dbpassword = "Kirkland9$";
$dbname = "spillout_mydb";

?>

File is saved.

In your web page that use connection to database you can type the following code to include connect.php file in the web page.

include('../conn/connect.php');

//code for connection:

mysql_connect( $hostname, $dbuser, $dbpassword)
                              or die ('Unable to connect to server.');

mysql_select_db($dbname )
                              or die ( 'Unable to select database.' );

$sql="select * from product" //let imagine that you have product table

              if(!$result=mysql_query($sql))
               {
               echo mysql_errno() . ": ";
               echo mysql_error() . "<br/>";
               }
               else
               {

               if(mysql_numrows($result))
               {
               //echo "some rows exist";

               while($row = mysql_fetch_row($result))
               {
               $product=$row[0];
               }

Example of using database for searching, inserting or updating records are given on web pages:

How to display data from MySQL on a web page

Demo PHP Application with MySQL database.

To create tables in the MySQL database and back up records you will use phpMyAdmin, which icon on the hosping panel is located next to MySQL database icon.



Did you find information useful? Send to your friend a link to this page

Please rate the tutorial

1 2 3 4 5 6 7 8 9 10



Comments
Register to add comments ( 1000 char ) for cpanel_file_manager.php.
Are you human? Please select two the same numbers