Members Login.
 

Please register HERE to be part of our Community
Latest Discussions ...
 

New topics in PHP
Contest of the Day.
 
Current Promotions.
 
Refer your friends to this forum and earn BRL per referred member.

Post a New Thread anywhere on Web Development Board to earn BRL$ 5 for every thread. Post a New Reply there and earn BRL$ 3 for every reply.

Post a New Thread anywhere on Search Engine Optimization Board and earn BRL$ 5 for every thread.
Earn By Posting
 
Participate in forum and Earn $$$.

Get Referrer Credit - BRL$ 20
Get Positive Rep Cr. - BRL$ 3
Get New Thread Cr.- BRL$ 3
Get Posting Cr. - BRL$ 2
Get Post size Credit

Full List of BRL$ Earnings
Sponsors.
 


PHP Discussion related to PHP web development, PHP coding. Tutorials, source code, tips and tricks related to PHP programming.

   

Creating/appending/linking to document (help writing blog)


This is a discussion on Creating/appending/linking to document (help writing blog) within the PHP forums, part of the Web Development category; Alright... I'm a beginning php coder and I think I'm in a bit over my head. I'm ...

Reply
  #1 (permalink)  
Old 09-09-2007
Administrator

Join Date: Jun 2007
Posts: 3,729
BRL$: 35,139.55
Thanks: 0
Thanked 7 Times in 7 Posts
Rep Power: 406
Rss_Feeds is on a distinguished road
Default Creating/appending/linking to document (help writing blog)

Alright... I'm a beginning php coder and I think I'm in a bit over my head. I'm writing my own blog (trying, at least), and I've run into some difficulty.I have currently written a php page that will both send information from a form (url, title, text, tags, date, and an auto_incrementing entry number) to a database and create a new page displaying that information. The form's fields are named rawtitle, rawtext, and rawtags. It looks like this (after the form):PHP:---------// to create url of blog post page $specialchars=array('/','!','&','*',"'",'"','.','?','@',';'); $pretitleurl1=str_replace('','',str_replace($speci alchars,'',$rawtitle)); $pretitleurl2=str_replace(' ','-',$pretitleurl1); $titleurl=stripslashes($pretitleurl2); $newfilepath = "blog/$titleurl.php"; $url=$newfilepath; // to send to db $insert="Insert into blogentries (url,title,date,text,tags) values('$url','$rawtitle',now(),'$rawtext','$rawta gs')"; mysql_query($insert) or die("Could not insert post"); // copy and rename template for blog post page copy('blog/template.php',$newfilepath); // write to the file $fileopen = fopen($newfilepath, 'a') or die("Can't open file"); // Title $title=stripslashes($rawtitle); $stringdata=$title; fwrite($fileopen, ''); fwrite($fileopen, $stringdata); fwrite($fileopen, '

'); // Dropcap $text=stripslashes($rawtext); $stringdata = $text; $cap=substr($stringdata, 0, 1); fwrite($fileopen, ''); fwrite($fileopen, $cap); fwrite($fileopen, ''); // Other text $text=stripslashes($rawtext); $text=substr($text, 1); $stringdata = $text; fwrite($fileopen, $stringdata); // Write bottom of page $stringdata = "</div> _uacct = "UA-139461-1";urchinTracker(); "; fwrite($fileopen, $stringdata); // close page fclose($fileopen);---------Apologies if my code is unclear, this is really the first hardcore php I've attempted and I'm well aware that the code itself is extremely shoddy. Allow me to clarify what's going on:The first block wipes all the special characters from the title and saves it as the url of the page. The next block sends all info to the database.Now, here's where it gets weird, mainly because I didn't know another way to do it -- the third section copies a "template" file that holds the (beginning) of the layout of the page being created. The file is then opened and appended, adding the content from the form and the end of the formatting information.Now, this section of the code works, but I'm wondering (actually, I'm sure there is) if there is a better way to do it. I would love some help cleaning up/optimizing the code, and I would also like some direction designing a similar function to create a page for each new tag input to the form displaying all entries with that tag. Once the page is created I know how to fetch and display the entries with the given tag, but I was wondering if you could use one function to create a page for each tag for which there isn't already a page (maybe with an array?). Since php overwrites any file already in existence, I guess it's unnecessary to check for any pages already there and just create a new page for each tag.


To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
__________________
High Quality
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

Powerful
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To receive latest updates about BRL Forums, Subscribe to Latest Updates Thread.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
blog, document, writing


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blog Your Way To Traffic Success. marketraisecorp Importance of Blogs 18 05-18-2008 02:16 PM
More New Blog Partners... Jason Link Exchange Strategy 0 07-14-2007 10:32 AM
How Link Exchange will improve your Blog Ranking Jason Link Exchange Strategy 0 07-14-2007 10:32 AM
$1 blog posts on Search Engine Marketing Blog mr_atom Buy / Sell Advertisements Board 0 06-11-2007 09:16 PM
10 Blog posts for $1 mr_atom Buy / Sell Advertisements Board 0 06-09-2007 06:53 PM


 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105