permaculture playing cards*
The moose likes PHP and the fly likes Overwriting deployment descriptor using PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Overwriting deployment descriptor using PHP" Watch "Overwriting deployment descriptor using PHP" New topic
Author

Overwriting deployment descriptor using PHP

Heather Rose
Ranch Hand

Joined: Aug 25, 2008
Posts: 54
Alright, this is a simple process, but I am quite new to PHP, so I'm having a bit of trouble.
This is what I need to do:

I have an index.php and a config.xml (DD).

On my index page, I have a form that (should) gather all the information FROM the config file and display those values in the text boxes. There are a few drop down menus as well.

Then, there is a save button. I need to be able to save the NEW values the user puts in and overwrite the old config file.

On a scale of 1-10, I'm basically a 1 on the PHP scale, so this is a little odd for me.

The problem I am running into is:
1) Fields not filling in correctly in the text boxes
2) There is an open tag somewhere on the top that I can't find (maybe because I'm unfamiliar with PHP) and is displaying all PHP code.
3) Breaks when trying to save.

Here is what I have in my XML:



And here is my PHP at the top of the page:



This what my form looks like:



I have attached an image of what the page is doing. For some reason, it wouldn't let me add 2 images, so I only added the one with the form. Any help would be appreciated.

Thank you.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

At first glance, the foreach seems a little fishy because you're shadowing $config. Even if that happens to be legal php, I'd recommend using a different "as" variable in the loop.

On the HTML side, it's a good idea to do value="something" with the quotes rather than value=something.

Also, the option tags have to many angle brackets >.

Hope this helps get things in the right direction for ya.


A good workman is known by his tools.
Heather Rose
Ranch Hand

Joined: Aug 25, 2008
Posts: 54
Alright, I have changed the />s and I fixed the html ""s, and nothing changed function wise.

I was a little confused on what you meant by:




At first glance, the foreach seems a little fishy because you're shadowing $config. Even if that happens to be legal php, I'd recommend using a different "as" variable in the loop.


Did you mean making the $config as $configVar or something and setting the $configVar to $config anyways, just to make things a little neater?
Heather Rose
Ranch Hand

Joined: Aug 25, 2008
Posts: 54
Another thing:

There must be something missing at the top, a broken tag or something, and I can't seem to find it. On my actual web browser when I run, this code shows up:



I tried to find where I messed up, but I couldn't seem to find it. This is the very beginning of my php code, and I didn't know if I missed just one thing, didn't close a tag, or didn't open one correctly. If you look at this code, and then look at the php code I provided above, it starts when it is loading the config file, so I'm pretty confused there too.
Heather Rose
Ranch Hand

Joined: Aug 25, 2008
Posts: 54
I am still confused and I have focused on ONLY making it print out the variables into the form in the text boxes.
I have researched a little bit, but I'm still confused. I haven't changed much, and I would still appreciate help.

Thanks.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

It sounds like you're heading in the right direction to isolate the problem by simplifying the page.

If you can get the page small and you still don't know what the problem is, please repost the smaller set of code.
Heather Rose
Ranch Hand

Joined: Aug 25, 2008
Posts: 54
I have replicating just the form and the PHP I need for ONE text box, and I can't seem to find what the problem is. Instead of printing the action, it's still printing the PHP. Please help me figure out what I'm missing.

Here's the PHP I'm using:


And here's the part of the form:


It's just printing out the <?php echo $hostname; ?>.

I'm at a loss. Please if you have ideas, let me know!

Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Either the file isn't .php or your server isn't configured to handle PHP.
Heather Rose
Ranch Hand

Joined: Aug 25, 2008
Posts: 54
Where the $hostname is coming from is a .xml file. I have loaded that at the top, and renamed the variable to hostname. From what I understand, you can do this using PHP (read in an xml file and then be able to parse it and display the values I want.

The config file is on top of this post if you want to have a look.
Thanks for all your help.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Heather Rose wrote:Where the $hostname is coming from is a .xml file.l

I don't think you understood what I was trying to communicate. Your server doesn't even realize that it needs to treat your PHP as code. Your server is treating all of your code as plain text and just dumping it all out as a plain text file. You need to figure out why none of it is getting treated like code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overwriting deployment descriptor using PHP
 
Similar Threads
Returning A List Of Variables From A Folder Of Documents And Returning Them Into A New Document
There is no Action mapped for action name prePaymentManager
Help with JSON
passing hidden forms problem
Submit dynamically created form with jQuery