1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Tutorial to create your own Myspace

Discussion in 'PHP' started by tim987, Feb 8, 2009.

  1. #1
    I read a tutorial on how to create your own Myspace script using PHP located here:

    http://www.upgradetheweb.com/2007/0...cecom-with-phppart-ii-designing-the-database/

    Being a php beginner, i'm wondering if someone can tell me what each line of the following php code means:

    The database class

    // Class: DbConnector
    ///////////////////////////////////////////////////////////////////////////////////////
    require_once 'DbVars.php';
    class DbConnector extends Dbvars {
    var $theQuery;



    function DbConnector(){
    // Load settings from parent class
    $settings = Dbvars::getSettings();
    // Get the main settings from the array we just loaded
    $this->host = $settings['dbhost'];


    // Connect to the database
    $this->link = mysql_connect($this->host, $this->user, $this->pass)or die(mysql_error());



    function query($query) {
    $this->theQuery = $query


    function getSettings() {
    // Database variables change accordingly
    $settings['dbhost'] = 'localhost'
     
    tim987, Feb 8, 2009 IP
  2. msmith78

    msmith78 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The first line, require_once includes the other php file. This is for including varibles or functions from that file.

    The next line creates a new PHP class called DbConnection

    Where there is function ... this create a new PHP function that can be then used in other files.
     
    msmith78, Feb 9, 2009 IP