• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overwriting deployment descriptor using PHP

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Heather Rose
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either the file isn't .php or your server isn't configured to handle PHP.
 
Heather Rose
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic