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!
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.
"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.
<?php if (file_exists("/XML_Upload/myFile.xml")) { $xml = simplexml_load_file($_SERVER['REQUEST_URI']."/XML_Upload/myFile.xml"); if (file_exists($_SERVER['REQUEST_URI']."/CONFIG/JOB_CONFIG_FILES/".$xml['Job_Name'])) { $details = simplexml_load_file($_SERVER['REQUEST_URI']."/CONFIG/JOB_CONFIG_FILES/".$xml['Job_Name']); $con = mysql_connect($details['servername'], $details['Username'], $details['Password']) or die ("Cannot connect to host: " . mysql_get_last_message()); mysql_select_db($details['DB_Name']) or die ("Cannot connect to database: " . mysql_get_last_message()); } else { echo "Failed reading XML"; } } else { echo "XML doesn't exists."; } ?> Code (markup): Quick one. You might need to play around with paths though.