Help - Search - Members - Calendar
Full Version: Sessions, content types and all sorts of crap
Weborum Webmaster Forum > Web Page Design > PHP
sjthomas
I'm a little confused on one of the applications I'm making. I'm generating an image so therefore setting the content type header info in php after setting up all the info to be displayed. Now I've got some options on the image that I want to preserve throughout a number of clicks and as I already use sessions to validate the user I thought it would be best to chuck those variables in there. Th eproblem I'm having is that when I call seeesion_start() at the top of the script it already thinks that info has been sent to the page and as such I can't modify the headers. If I comment out the session_start() it works fine but obviosuly I can't access any session information. Is there anyway round this?

Also I'm looking for a tutorial/resource/guide on using XML with php, specifically if there is a way to use a DTD to control the operations as opposed to just hard coding it into the page. So basically a way to tell the program what format the xml should be outputted/input as through a DTD so that it can be easily changed and still cope. I've seen ways to create and read (parse) xml documents using the native support but nothing to do with DTD's.

Any ideas on either of those? cigar.gif
aviansuicide
The first one:
PHP

<?
ob_start
(); //first line of script
/* ..... */ //script
ob_end_flush(); //last line of script
?>



The second..I don't use the XML abilities of PHP because I find them a lot more work than they're worth...but bearing that..I'm gussing you want to customize the appearance of XML generated by PHP,yes?

In which case you want to use an XSL style sheet...not a DTD.A DTD defines the taglib of the document...not how it's displayed.
sjthomas
Ah output buffering! Didn't think of that lol

Nah its a DTD I want to use to control the schema not an XSLT. I have a DTD made up and some sample XML files but I'm not sure how, or even if its possible to link the XML parsing to the DTD.

For a bit of background on it. I'm going to start off offering one type of XML document but I hope to support others in the future when some standards come out fo rthe area, I'd like to be able to do this by just adding a DTD as opposed to chagning the code.
aviansuicide
QUOTE(sjthomas @ Mar 14 2005, 03:53 PM)

Nah its a DTD I want to use to control the schema not an XSLT.  I have a DTD made up and some sample XML files but I'm not sure how, or even if its possible to link the XML parsing to the DTD.


See...the way you said it..."DTD" "Formatting" "display" in the same sentence made me think "He's looking for style sheets"...NOW it makes sense.

QUOTE(sjthomas @ Mar 14 2005, 03:53 PM)
For a bit of background on it.  I'm going to start off offering one type of XML document but I hope to support others in the future when some standards come out fo rthe area, I'd like to be able to do this by just adding a DTD as opposed to chagning the code.
[right][snapback]24638[/snapback][/right]


So what you want to do..for example...output the 'same' xml document with a different doctype?Why couldn't you use a conditional(eg: if/switch statement)?As far as input...don't the XML features of php determine the doctype automatically from the file?

I'd have to sit down and play with the xml features to be of any specific help to you...and since I don't endorse php5..and php4's xml support is rather different...I doubt I can be of any specific help.
sjthomas
QUOTE
don't the XML features of php determine the doctype automatically from the file?


As far as I'm aware it does when your parsing an xml document but not when creating it.

To me it seems like an obvious thing to do, I'll continue looking around though.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.