Showing posts with label php training los angeles. Show all posts
Showing posts with label php training los angeles. Show all posts

Saturday, January 14, 2012

How to connect to a MySQL Database Using PHP - ABCO Technology

ABCO Technology explains, I'd like to explain to our students on creating a config file, which is the first part of creating any application.  I'll start from phpMyadmin.  Connect to the phpmyadmin interface for MySQL and create a database along with the user.  For this purpose we are going to assume that we are creating a blogtastic database for a web blog, and a user named blog_usr, with a password "password".  You will obviously have your own credentials, If the MySQL database and the PHP Code is on the same server, then your host will be "localhost", or you will have to type the name or IP address of your database server.

After the database is created, using a simple HTML editor, create a config file, in which you will create variables for your site.  These are variables that are going to be used throughout the site, and hence must be defined in the config.php file.  This also makes the website more scalable, as in the future, if you change the server or the database, you will have to only make the changes in one place.


The most important point to remember is the fact that on every page of your site, where you need to retrieve information from the database, or send information to the database, it is required to connect to the database at the very top.  


So here's a sample config.php file, that you must prepare at the start of every application.  Once the file is prepared, include this file at the top of every page using the include("config.php") or require ("config.php") function.  You may watch a video of this file at the following link: "ABCO Technology presents how to connect to MySQL from PHP"

SAMPLE CONFIG.PHP File:

<?php

//define the variables for the database

$dbhost = "localhost";
$dbuser = "root";
$dbpassword = "password";
$dbdatabase = "blogtastic";

//Other site related variables

$config_sitename = "The Ultimate Blog";
$config_baseurl = "http://localhost/projects/blogtastic";
$config_author = "ABCO Technology";

//functions to connect to the database

$db = mysql_connect($dbhost, $dbuser, $dbpassword); //connects to the database
if(!db){
echo "Not Connected to the database";
}

$dbselect = mysql_select_db($dbdatabase,$db); //selects the database

?>

Please feel free to write comments so we can get a proper feedback.  For more information please contact us at ABCO Technology at (310) 216-3067.  This blog is part of the Advanced PHP Course taught at ABCO Technology.  Visit our website for more details.

Check Us Out We Are All Over The Web!!






Check Out Our Website

Friday, October 7, 2011

Create Dynamic HTML Pages using PHP

One of the most interesting things of PHP is that it can be used on different types of operating systems including Microsoft Windows, Unix variants, RISC OS, Mac OS X, Linux and several others. Apart from this, PHP supports almost every web servers. Some of them are Microsoft Internet Information Server, Apache, Netscape, Personal Web Server, OmniHTTPd, Oreilly Website Pro server, Xitami and Caudium.


In most of the time PHP uses object oriented programming or a procedural programming for server-side scripting, writing desktop application and command line interface. However, for using PHP in a server-side scripting, one require a PHP parser, a web browser and a web server. But in this respect it should also be mentioned that PHP script could be run without a browser or a server. This type of usage is actually executed using Task Scheduler or cron. Moreover, these scripts can be used for the tasks of simple text processing.
Beside all these usages, PHP can be used for the creation of a desktop application with a graphical user interface. On the other hand, with PHP-GTK one will be able to write cross-platform applications. There is no doubt in the fact that since PHP websites have more features, they are considered to be better than the regular websites.
While discussing about PHP, it should also be mentioned that PHP allows for the outputting of PDF files, Flash movies and even images. If you want you can also output text in different forms, such as, XHTML as well as any other XML file. PHP basically auto generates those files and saves them in the file system.
PHP supports a wide variety of databases, such as, Postgre SQL, Adabas D, InterBase, FrontBase,SQLite, dBase, Empress, mSQL, Direct MS-SQL, Solid, FilePro, Velocis, Sybase, Hyperwave, MySQL, Informix, Oracle, ODBC (Open Database Connection), Unix dbm, Ovrimos and Ingress.
PHP also uses several protocols (such as, NNTP, POP3, IMAP, SNMP, HTTP, COM, LDAP). Apart from this, PHP has support for the WDDX complex data exchange between different web programming languages and instantiation of Java objects. On the other hand, for accessing and parsing XML documents, PHP 4 supports the DOM and SAX standards, whereas, PHP 5 standardizes most of the XML extensions on libxml2.
Nowadays, most of the programmers of a reputed web development company are expected to know PHP, otherwise they may face trouble while delivering quality web development services.




Check Us Out We Are All Over The Web!!






Check Out Our Website