newbie - writing a file

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!

Moderator: General Moderators

Post Reply
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

newbie - writing a file

Post by kippy »

How can you write php code and html code into a newly created file all using php script? When I attempt to place the html and php code in the variable to write to the new file, the script has problems writing the new infor to the file. I think it has something to do with the quote marks within the content I am trying to write. Any help is appreciated.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: newbie - writing a file

Post by Ambush Commander »

It would be helpful if you posted the code you were running, but it sounds like you've either got a permissions problem or a flat out invalid filename. Also, why are you generating PHP with PHP?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: newbie - writing a file

Post by RobertGonzalez »

kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Re: newbie - writing a file

Post by kippy »

Well basically what I want to do is when someone registers on my site I want a new directory to be created and inside that directory I want a new index file to be created and inside this new file there will php. So basically I have to use php to create a brand new page that contains html and php in it. I hope that makes sense.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: newbie - writing a file

Post by RobertGonzalez »

You may want to rethink your structure here. You could easily handle this with a single bootstrap file, a database and some url rewriting.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: newbie - writing a file

Post by Ambush Commander »

Indeed. What happens if you need to update the PHP code?
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Re: newbie - writing a file

Post by kippy »

Mr. Modnificent can you give me an idea on how you would handle it? I am not familiar with a bootstrap file, etc. Thanks.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: newbie - writing a file

Post by RobertGonzalez »

Basically all you need is one file that handles data fetches for a user based on the user name or something like that. So instead of having /user1 /user2 you would need like /index.php which would take a query string var of say userid (like /index.php?u=<userid>) where <userid> is a number of the user.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Re: newbie - writing a file

Post by kippy »

I was planning to create a new directory for each registration...inside these directories would be the index.php that could display that users information etc. How can I generate a new directory with the same dynamic index file included? Thanks.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: newbie - writing a file

Post by RobertGonzalez »

You would make the index page (the bootstrap) handle the request for the users information. Rather than building 500,000 identical pages (yes, I think big) you build one page that fetches the information for that user the way you want to fetch it.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Re: newbie - writing a file

Post by kippy »

I was planning to use seperate directories so the user would have a url to remember and be specific to them...almost a mydomain.com/users/name they define...is that possible?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: newbie - writing a file

Post by RobertGonzalez »

That is more than possible. One file, everything for a user pushed through it by username. Super simple concept. Think mod_rewrite.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Re: newbie - writing a file

Post by kippy »

Thanks, I will see what I can do...
Post Reply