Jump to content

Search the Community

Showing results for tags 'blog'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. So I started a blog project just to help me out with learning php. This is my post form <form action="insert.php" method="post"> Title: <input type="text" name="title"> <br> Post: <input type="text" name="post"> <br> Author: <input type="text" name="author"> <br> <input type="submit"> </form> Insert.php <?php $con = mysqli_connect("localhost","test","","test"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for security $title = mysqli_real_escape_string($con, $_POST['title']); $content = mysqli_real_escape_string($con, $_POST['post']); $author = mysqli_real_escape_string($con, $_POST['author']); $sql="INSERT INTO article (title, content, author) VALUES ('$title', '$content', '$author')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?> But when I try to display that information here: <h1>Title: </h1> <?php echo $title; ?> <h2>Content: </h1> <?php echo $content; ?> <h3>Posted by: </h1> <?php echo $author; ?>It doesn't work and I get this: ( ! ) Notice: Undefined variable: title in C:\wamp\www\test\index.php on line 33 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 Content: ( ! ) Notice: Undefined variable: content in C:\wamp\www\test\index.php on line 34 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 Posted by: ( ! ) Notice: Undefined variable: author in C:\wamp\www\test\index.php on line 35 Call Stack # Time Memory Function Location 1 0.0000 239144 {main}( ) ..\index.php:0 The form works because when I looked at the database, the information was there. The problem is getting that information and displaying it in the right place, how can i fix that? Just in case, this is my index: <?php include ('connect.php'); include ('header.php'); ?> <div id="container"> <div id="rightcol"> <form action="insert.php" method="post"> Title: <input type="text" name="title"> <br> Post: <input type="text" name="post"> <br> Author: <input type="text" name="author"> <br> <input type="submit"> </form> </div> <div id="content"> <h1>Title: </h1> <?php echo $title; ?> <h2>Content: </h1> <?php echo $content; ?> <h3>Posted by: </h1> <?php echo $author; ?> </div> </div> <?php include "footer.php"; ?> </div>
  2. Ok so basically I have created a simple blog for my website which does what I want it to do pretty much I'm having a problem with the date though If I echo the date out in to my page it just shows the main body of my content and not the actual date :/ the other problem is when I am echoing the blog into my page It is showing the same content two or three times instead of selecting the other content in the db I currently have two articles in my db but it will only show the article with the id of 1 instead of outputting id 1 and id 2 into there respective places on the page <?php $mysql = new mysqli('localhost', 'root', 'root', 'blog') or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT id, title, date, author, category, LEFT(body, 600) AS excerpt, body from posts ') or die('Problem preparing the query'); $stmt->execute(); $stmt->bind_result($id, $title, $body, $author, $category, $excerpt, $date); while($row = $stmt->fetch()) : $lastspaceindex = strrpos($excerpt, ' '); ?> <?php endwhile; ?> then where I am echoing them out here my code is <div class="extra-wrap"> <span class="text3"><a href="blog.php?id=<?php echo $id; ?>" class="link1"><?php echo $title; ?> </a></span> <div class="inner4"> <p> Posted by <b><?php echo $author; ?></b> in <b><?php echo $category; ?></b> </p> </div> </div> <div class="clear"></div> <div class="page2-box2"> <figure class="page2-img1"><img src="images/page2-img2.jpg" alt=""></figure> <div class="extra-wrap"> <?php echo substr($excerpt, 0, $lastspaceindex) . "<a href='blog.php?id=$id'>...</a>"; ?><br> <span class="text3"><?php echo substr() . "<a href='blog.php?id=$id'>Read More</a>"; ?></span> </div>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.