SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,759
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    File writing a "default page"

    EDIT- Just need to find out why variables aren't being written in the fwrite function. my $pageIdentity isn't being written (it being a variable). That whole word is being ommited

    Hello. I'm currently making a blog and long story short, I'm almost done. I've decided that upon me submitting the blog form, it will tkae the information, store it in the database, and then it will create the page (and thus from there it will have the article written)

    I'm wondering if there's a way to make THIS code
    Code:
    <?php $pageIdentity="Blog".;
    include("../../settings.php");
    ?>
    <div id="wrapper">
        <?php include("../../header.php");?>
        <div id="main">
            <?php include("../../menu.php");?>
            <div id="page">
                    <div id="content">
                        <div class="post">                            
                            <h2 class="title"><a href="#">Blog Homepage</a></h2>
                            <p class="meta">Posted  on  &nbsp;&bull;&nbsp; <a href="#" class="permalink">Full article</a></p>
                            <div class="entry">
                                <p><img src="../images/img04.jpg" width="186" height="186" alt="" class="alignleft border" />Article Content goes here.</p>
                            </div>
                        </div>
                    </div>
    <?php include ("../../sidebar.php");?>
            </div>
        </div>
        <?php include("../../footer.php");?>
    </div>
    </body>
    </html>
    Be the default code that's written in the file (the fopen() function will create the page and I want that to be defaulted)

    Here is what I have for my submission page
    Code:
    $insertionToDatabase="INSERT INTO $tableName (PostNumber, DateTime, Content, type, URL) VALUES (NULL, FROM_UNIXTIME($dateTime), '$contentOfPost', '$type', '$URL')";
    
    
    $result = mysql_query($insertionToDatabase);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    else
    {
    $fh = fopen($URL, 'w') or die("can't open file");
    $stringData = "";
    fwrite($fh, $stringData);
    
    
    fclose($fh);
    }
    I have more than that but you shouldn't need to see any more. Basically if the results get entered into the database, write the file. $stringData I want to contain the first code segment I posted above.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,759
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    EDIT- Just need to find out why variables aren't being written in the fwrite function. my $pageIdentity isn't being written (it being a variable). That whole word is being ommited

    Right now I have this, which is almost working.
    ryanreese.us/blog/contain-floats.php

    It's giving a server error. Based on previous attempts...I don't think this section is working.
    Code:
    $stringData = "<?php
    $pageIdentity=\"Blog- \".$URLtitle;
    Here is the attempt below.
    Code:
    $insertionToDatabase="INSERT INTO $tableName (PostNumber, DateTime, Content, type, URL) VALUES (NULL, FROM_UNIXTIME($dateTime), '$contentOfPost', '$type', '$URL')";
    
    $result = mysql_query($insertionToDatabase);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    else
    {
    $fh = fopen($URL, 'w') or die("can't open file");
    $stringData = "
    <?php
    $pageIdentity=\"Blog- \".$URLtitle;
    include(\"../../settings.php\");
    ?>
    <div id=\"wrapper\">
        <?php include(\"../../header.php\");?>
        <div id=\"main\">
            <?php include(\"../../menu.php\");?>
            <div id=\"page\">
                    <div id=\"content\">
                        <div class=\"post\">                            
                            <h2 class=\"title\"><a href=\"#\">Blog Homepage</a></h2>
                            <p class=\"meta\">Posted  on  &nbsp;&bull;&nbsp; <a href=\"#\" class=\"permalink\">Full article</a></p>
                            <div class=\"entry\">
                                <p><img src=\"../images/img04.jpg\" width=\"186\" height=\"186\" alt=\"\" class=\"alignleft border\" />Article Content goes here.</p>
                            </div>
                        </div>
                    </div>
    <?php include (\"../../sidebar.php\");?>
            </div>
        </div>
        <?php include(\"../../footer.php\");?>
    </div>
    </body>
    </html>";
    fwrite($fh, $stringData);
    
    
    fclose($fh);
    }
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  3. #3
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,759
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Derp. Figured it out. I was trying to echo variables inside of an echo..just needed to make it something like ".$var." etc and it worked...everythings fine now.

    I'm so close to being done this blasted script .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •