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 Interfejs! HELP

Discussion in 'PHP' started by neomatrix, Jun 17, 2012.

  1. #1
    HELLO PPL,

    I have a php file called index.php

    This file should connect to a mysql database.

    The Login Informations are stored in a XML file on the server

    HOW COULD I DO THIS:

    When you open INDEX.php it opens a XML file where a name is stored in the folder /XML_Upload/

    it checks if a file with the "*.xml" extension exists

    If so it opens the xml file and reads the first NODE that is <Job_Name>

    IT READS THE NAME AND THEN it looks in the folder called CONFIG/JOB_CONFIG_FILES/

    and opens the XML file called <Job_Name>.xml

    in this file it reads 4 nodes <servername>Localhost</servername>

    <Username>Username</Username>

    <Password>Password</Password>

    <Database_Name>DB_Name</Database_Name>

    and then it connects to the server with this informations!!!!!


    PLZ ANY HELP also a little tiny code snippet would be great i am new to .php

    I am using WAMP Server and PHPMYADMIN to test this out.

    Normaly i am a VB.Net developer and need to do a little php in my project!!!

    THX ALL in advance!
     
    neomatrix, Jun 17, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,883
    Likes Received:
    34
    Best Answers:
    51
    Trophy Points:
    100
    #2
    Write it in VB (which should be trivial for you). Translate it to PHP (it's not that difficult). The experience will teach you a lot about PHP. I've actually ported tons of VB6 code to PHP, to move a company from doing it on the desktop to doing it on their site, and once you see how it's done, and develop your own methods for translating, it's almost trivial.
     
    Rukbat, Jun 17, 2012 IP
  3. NetStar

    NetStar Well-Known Member

    Messages:
    1,413
    Likes Received:
    210
    Best Answers:
    19
    Trophy Points:
    115
    #3
    Take a look at simplexml_load_file() to read values from an XML file.
     
    NetStar, Jun 17, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,883
    Likes Received:
    34
    Best Answers:
    51
    Trophy Points:
    100
    #4
    "Give a man a fish ..." simplexml is almost trivial, and it's the way to go, but I think learning PHP almost as well as he already knows VB, with very little effort, would be something he'd want to do.
     
    Rukbat, Jun 18, 2012 IP
  5. Custom IDX/MLS

    Custom IDX/MLS Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Code (Text):
    1.  
    2. <?php
    3. if (file_exists("/XML_Upload/myFile.xml")) {
    4.     $xml = simplexml_load_file($_SERVER['REQUEST_URI']."/XML_Upload/myFile.xml");
    5.     if (file_exists($_SERVER['REQUEST_URI']."/CONFIG/JOB_CONFIG_FILES/".$xml['Job_Name'])) {
    6.         $details = simplexml_load_file($_SERVER['REQUEST_URI']."/CONFIG/JOB_CONFIG_FILES/".$xml['Job_Name']);
    7.         $con = mysql_connect($details['servername'], $details['Username'], $details['Password']) or die ("Cannot connect to host: " . mysql_get_last_message());
    8.         mysql_select_db($details['DB_Name']) or die ("Cannot connect to database: " . mysql_get_last_message());
    9.     } else {
    10.         echo "Failed reading XML";
    11.     }
    12. } else {
    13.     echo "XML doesn't exists.";
    14. }
    15. ?>
    16.  
    Quick one. You might need to play around with paths though.
     
    Custom IDX/MLS, Jun 19, 2012 IP