Jump to content

less database interaction


neerajpuri

Recommended Posts

hii m new to php....so getting lots of problemsI want less database interaction in my portal......the thing is i wana use xml.......i want the same thing which is done in ibnlive.com site......the data is fetched thru xml n then converted to html page n the page is called by the unique autogenerated id.........i m using php.............i think it is parsing of xml pages but no exact idea............hw do i do that........

Link to comment
Share on other sites

Hi there, I admit XML is pretty neat. You need to check the PHP docs. They should be included with your web-server or you can find them online. PHP has had functions to parse XML since 3.0.6 (e.g. xml_parse() and others). You do still need to think a bit about how your info is stored though. I would follow some sort of template like this:

<?xml version="1.0" encoding="UTF-8"?> <data>  <heading>Page Heading</heading>	<body>	  <![CDATA[	   The body of the text.... Stuff stuff...	  ]]>	</body>	<info>Some other info</info> </data></xml>

Notice the use of the <![CDATA[, this allows you to put html tags and such into the body tag. Without this, any images or links or general html tags you decide to use will be parsed as XML.The next step is to then pull this data out of the XML file and replace them into a template.

Link to comment
Share on other sites

Hi there, I admit XML is pretty neat. You need to check the PHP docs. They should be included with your web-server or you can find them online. PHP has had functions to parse XML since 3.0.6 (e.g. xml_parse() and others). You do still need to think a bit about how your info is stored though. I would follow some sort of template like this:
<?xml version="1.0" encoding="UTF-8"?> <data>  <heading>Page Heading</heading>	<body>	  <![CDATA[	   The body of the text.... Stuff stuff...	  ]]>	</body>	<info>Some other info</info> </data></xml>

Notice the use of the <![CDATA[, this allows you to put html tags and such into the body tag. Without this, any images or links or general html tags you decide to use will be parsed as XML.The next step is to then pull this data out of the XML file and replace them into a template.

ok......tanx..........i'l try that
Link to comment
Share on other sites

You also might want to know some info on the difference between databases and files. -Databases are faster -Databases are also less secure -You can organize and find things in a database easier, in files you could make you own sort of "phpmyadmin" but for a file..There are a few more things but that is just the main things.

Link to comment
Share on other sites

You also might want to know some info on the difference between databases and files. -Databases are faster -Databases are also less secure -You can organize and find things in a database easier, in files you could make you own sort of "phpmyadmin" but for a file..There are a few more things but that is just the main things.
How are databases less secure?
Link to comment
Share on other sites

-Databases are also less secureThere are a few more things but that is just the main things.
Yeah right. In order to view an XML file, I only need to know it's location. If it's encrypted I also need to decode it's data of course.With a database I need to know the server and port the DB is on and I need to know a username and password to use it. If I know this and the data is encrypted, I again need to decrypt it.Scince when does knowledge of a location count as less more secure then a username and password?
-You can organize and find things in a database easier, in files you could make you own sort of "phpmyadmin" but for a file..
It really depends on what type of expressions are you comfortable with. I've always prefered
//members/phone

then

SELECT phone FROM members

And organization also depends on the individual. I would have a few structured folders of XML files and access them separatly, depending on what I need. This could also help increase performance. XSLT also has a key() function that very closely emulates DB's relations, so that's not that much issue either (IF you manage to master this function, as I yet have to).................On the topic. I strongly suggest that instead of PHP you use XSLT to transform the XML into XHTML. Use PHP only to execute that transformation and show the output to the browser. If you need other server side only features, you could pass the results of those operations as parameters to the XSLT for futher processing.

Link to comment
Share on other sites

How is it that a database is less secure? While I would say that if you took all the precautions, they can both be safe methods of accessing files, the database itself is in general "safer".For one, most of the access comes internally. The sql host and password are all handled server side and the client sees or hears nothing of that connection. Also, if the system DOES get compromised, a person with database access can only destroy your data. A person with file-system access can destroy data (they could very well look at your scripts for the db passwords) AND install malicious script, up to damaging the actual server.But I still think that if used correctly, both methods are safe. It just depends on what your needs are.

Link to comment
Share on other sites

ok i'l use xslt....tanx alot

Yeah right. In order to view an XML file, I only need to know it's location. If it's encrypted I also need to decode it's data of course.With a database I need to know the server and port the DB is on and I need to know a username and password to use it. If I know this and the data is encrypted, I again need to decrypt it.Scince when does knowledge of a location count as less secure then a username and password?It really depends on what type of expressions are you comfortable with. I've always prefered
//members/phone

then

SELECT phone FROM members

And organization also depends on the individual. I would have a few structured folders of XML files and access them separatly, depending on what I need. This could also help increase performance. XSLT also has a key() function that very closely emulates DB's relations, so that's not that much issue either (IF you manage to master this function, as I yet have to).................On the topic. I strongly suggest that instead of PHP you use XSLT to transform the XML into XHTML. Use PHP only to execute that transformation and show the output to the browser. If you need other server side only features, you could pass the results of those operations as parameters to the XSLT for futher processing.

Link to comment
Share on other sites

Hmm, well secureness depends on what your dealing with. If its passwords and stuff no go. But there still isnt really a way to edit it, to the contrary with files, which you cant edit withoout FTP. So it just depends. :)

Link to comment
Share on other sites

XSLT is more XML, and honestly i would try to stay away from it, XML is good for RSS, other than that almost anything you do with XML can be done alot faster in PHP and MySQL. As for the XML thing, if you really want i believe there is a function called simple_xml_loadfile, and once that is loaded you can pretty easily get values set from the XML file and display them however you want.And boen_bot, how are databases less secure than xml? XML can be viewed by anyone with a browser, databases can be only used and viewed by one who can connect to the server with the right permissions.

Link to comment
Share on other sites

XSLT is more XML, and honestly i would try to stay away from it, XML is good for RSS, other than that almost anything you do with XML can be done alot faster in PHP and MySQL.
So what if it's "more XML"? Does XML have a complex syntax or anything? Better performance is a plus for DBs, but the minus is mixing logic with presentation. Wouldn't you rather prefer having the same logic over several presentaions?
And boen_bot, how are databases less secure than xml? XML can be viewed by anyone with a browser, databases can be only used and viewed by one who can connect to the server with the right permissions.
You are mistaken. reportingsjr said that, not me. Not only I haven't said DBs are less secured then XML, but I claimed otherwise. I edited the sentence
Scince when does knowledge of a location count as less more secure then a username and password?
before your post because I noticed my factological error. I was rithorically asking if a knowledge of a location is more secure then having a user name and password and we both realize- it never was. Having a user name and password the way that databass have was, is and will be more secured.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...