Open Side Menu Go to the Top

03-08-2008 , 03:42 PM
If anyone is out there trying to make a website using PHP & MySQL and is stuck or confused about anything, we can post ITT and help each other through it.

An example would be even if you have an idea for a website that would make you $ but don't want to start because you are confused about site security, you would post that question here.

I'll start I guess by saying that i was recently hired at a web portal company so my PHP isn't very strong (which is why i'm making this thread) but then again if you know Java/C you know PHP...

Without revealing too much about the website, I have users who can save things about them so next time they log on they can see what they changed. My first try through this I used .txt (lol) with a format like this:

Code:
user:pref1,pref2,pref3
Used PHP's explode function to get the left side of the colon (group) and the right side was re-exploded by commas to get each pref in an array.

however obv. that wasn't going to last long and wasn't a longterm solution...so i've changed it to xml:

Code:
<group>
     <username>test</username>
     <prefs>pref1</prefs>
     <prefs>pref2</prefs>
     <prefs>pref3</prefs>
</group>
and i used PHP's SimpleXMLElement to retrieve the information, and that worked for displaying it.

However now i want to remove a node, and SimpleXMLElement doesn't remove nodes. After some google searching PHP's DOMDocument (used in php 5+, DOM XML was deprecated) was the thing i should use.

Not a lot of good documentation is on this however, and after a couple days i was able to display my information using the following code:


[PHP]
//load prefs.xml
$fileN = getUD($uID);
$fileN .= "prefs.xml";


//openDomXML is my function i wrote, just calls
//DOMDocument->load();
$prefList = openDomXML($fileN);
$prefList->getElementsByTagName("group");

echo "<pre>";
print_r($prefList->saveXML());
echo "</pre>";
[/PHP]

I guess "saveXML()" shows the text of the xml, but not the tags.

Has anyone used DOMDocument before? Any references/GOOD run throughs you want to point me to? I want to use the best O(n) code possible to make this work efficiently. The FIRST time i write it.

Thanks!


For those interested in website development (i am still struggling with CSS)
http://www.w3schools.com/ is a great place to start. you can also use your home computer as a PHP server for testing before you drop $ on a domain name, download wamp5:
http://www.wampserver.com/en/
installs php5, apache, mysql...

and for reference, http://www.php.net has oodles of information.

Good luck
Website Development Thread Quote
Website Development Thread
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
Website Development Thread
03-08-2008 , 03:54 PM
Your method of storing user data is horrible. Google for MySql databases, install and use it. How ffs can someone write php-scripts and does not know about MySql?

Why in the world do u use DOMDocument, this is just so stupid.

You work for an web portal company?
Website Development Thread Quote
03-08-2008 , 03:58 PM
yes i work for an web portal company, and yes i use a mysql db to store the critical user info - maybe i'm just not seeing how i can store the info on my user efficiently in a db if it can be rather large (the example i used is not really prefs - it's more integrated than that and can become complex, if i said what it really was it'd give away info about the site)
Website Development Thread Quote
03-08-2008 , 04:04 PM
You can store anything in that database, no matter how large it is -.-

You work in a web company and do not even know about css? Great company ^^
Website Development Thread Quote
03-08-2008 , 04:11 PM
OK i can see where this is going. Thx for the help!
Website Development Thread Quote
Website Development Thread
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
Website Development Thread

      
m