Akenatehm Posted November 22, 2008 Share Posted November 22, 2008 Hey Guys, I was wondering if anyone knew of a PHP script that will write data from a mysql database into an XML File. I don't need the PHP script to display anything but to just write the data from the database to the xml file at a time interval. Help would be greatly appreciated. Thanks in Advanced Akenatehm Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/ Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 simplexml Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696503 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 Do you think you could be a little more specific and give some details about what I would have to set up, and how hard it would be? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696517 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 What database you use Would do you know about PHP and database programming? Such script would not be very difficult, but could pose some problems to real novice. Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696520 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 I use a MySQL database through phpMyAdmin. I don't know a lot about database programming or PHP although I can understand some of it. Is there any way you could assist me with creating this script? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696527 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 There are two ways: You can post it in Freelancing section and hope someone willing to do it (for a price or otherwise) or You can try to do it by yourself, and if you have problems, ask questions here, and you surely will be helped. Just show that you're willing to learn. First thing that I would advise you to do, is to learn how to connect PHP to MySQL. Here's manual page for mysqli extension, that will be useful. Take a look at Example #1 and try to do it yourself. Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696531 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 So far I have this script: <?PHP $link = mysql_connect("localhost","username","password"); mysql_select_db("kaurlcom_messenger"); $query = 'SELECT * FROM users'; $results = mysql_query ($query); echo "<?xml version=\"1.0\"?>\n"; echo "<users>\n"; while ($line = mysql_fetch_assoc($results)) { echo "<username>" . $line["username"] . "</username>\n"; } echo "</users>\n"; mysql_close($link); ?> Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696534 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 So that's not a bad start. You have a database connection, and a query retrieving data. In fact it should produce pretty good xml. What problems do you have with it? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696541 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 Whenever I try to open it in a browser it says the page cannot be found (Error:404. A PHP friend said it would be because I don't have a index.php file but idk if thats right? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696545 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 No. This should not be a problem. What is the file name of the script, and how do you open it in browser? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696554 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 The name is users.php I access it by going through www.mydomain.com/public_html/users.php Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696557 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 how about www.mydomain.com/users.php ? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696561 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 Still says error, page cannot found....before when I got it to load locally it came up with a whole lot of errors but thats about it... Any ideas to fix? Do you have an MSN or Yahoo that I can add so we can talk through this problem easier? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696565 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 Hello? Anyone? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696571 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 Do you have any other files on this account? Can you open them in the browser? Maybe you should try to create a simple HTML page, and try to open it to see if it loads all right (which will tell us, that all is OK with your server) 404 error is not caused by script itself, but most likely because you've placed script in wrong place or you're typing in wrong url. Sorry, I don't use neither MSN nor Yahoo, and besides it's getting late here... I guess someone else will have to try to help you... I'll be back tomorrow Good luck Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696574 Share on other sites More sharing options...
dezkit Posted November 22, 2008 Share Posted November 22, 2008 Put the script in "root/public_html/" not "root/public_html/public_html" Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696575 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 Does the XML file already have to be created for it to write to it or will it automatically be created? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696579 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 I have tried it in both the root folder and in /public_html. There is no directory on my site called /public_html/public_html Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696583 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 I tried opening it in root/public_html (again) and nothing happened Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696584 Share on other sites More sharing options...
dezkit Posted November 22, 2008 Share Posted November 22, 2008 Have you written anything in your htaccess lately, and are you using cPanel or no? Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696586 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 No, not in htaccess but I may have deleted when I was using Dreamweaver. The FTP Sync on there is not the best. Yes I am using cPanel. It just worked now. But when I deleted it from the server to try an updated version nothing has changed and it still loads the page normally in both chrome and ie even though in the file browser in the cPanel, it shows the file as not there. Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696591 Share on other sites More sharing options...
Akenatehm Posted November 22, 2008 Author Share Posted November 22, 2008 I also just noticed that there is no .htaccess file in the root directory of my site and when I save it as another file name like original file is called test and then the second one is test2 it says that test2 doesn't exist Link to comment https://forums.phpfreaks.com/topic/133830-solved-script-that-writes-data-from-a-mysql-database-to-an-xml-file/#findComment-696594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.