PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hi all...i am very new to php, but i find it very cool. Flash is more my gig, but i have discovered the value of these two communicating. I am making a pin up note board...literaly has notes that you can pin/de-pin. All said, the notes get there info from an XML that loads thanks to PHP. My dilema is making new notes...i understand how to write a file with php (fopen, fwrite, fclose) and i know i can add to that file, but how can i add text after the first xml tag. In this example how can i add <point> this is entry four</point> between the last and 2nd to last nodes?
<entries>
<point>This is entry one</point>
<point> this is entry two</point>
<point>This is entry three</point>
<point> this is entry five</point>
</entries>
i have tried making an array with the nodes, and using <point> as a delimeter...but i am getting confused...is that the right track? Do the tags mess up PHPs ability to delimit? hmmmmm
bokehman- just wanted to say thanks , and to follow up...so your help was right on. The file command got the arrays i needed to write to file. Final code ended up:
bokehman- always learning here...so the @ is the same as if(!..)? As i stated from the get-go, i am new to PHP. If you can explain @fopen, would love it...thanks
Last edited by mlecho on Thu Jun 22, 2006 2:24 am, edited 1 time in total.
mlecho wrote:bokehman- always learning here...so the @ is the same as if(!..)? As i stated from the get-go, i am new to PHP. If you can explain @fopen, would love it...thanks
The @ just suppresses the error from the fopen. There's no point having two error messages; you already have one in the die().
This works because there is an "or". If the first statement returns false the second will be run. It's as simple as that. This construction seems really common when used in conjunction with mysql queries but works fine everywhere.