-1

When I have PHP in my file, the page shows blank and when looking at the source it shows that their is totally no tags on the page. When I remove my PHP the form shows just fine, but when the PHP is there.

<?php
$title = $_POST['title'];
$subcontent = $_POST['subcontent'];
$content = $_POST['content'];

if(empty($content)){
    echo "<p>Create a new post</p>";
}
else{
    echo "<p style='color:green;'>success</p> " . $content;

$time = date("j, n, Y"); 

$db = new mysqli("localhost", "admin", "pass", "db");
mysqli_query($db, "SELECT * from Articles");
mysqli_query($db, "INSERT INTO Articles (Title, subcontent, Content, Date) VALUES ('$title', '$subcontent' ,'$content', '$time')");


?>
<!DOCTYPE html>

<html>
<head><title>Post a new article</title></head>

<body>

       <form method="post">
            <input type="text" name="title" placeholder="Enter post Title"/>
            <input type="text" name="subcontent" placeholder="Enter sub-content"/>
            <input type="text" name="content" placeholder="Enter content"/>
            <input type="submit" value="post"/>
        </form>


</body>
</html>
Ajax jQuery
  • 357
  • 1
  • 5
  • 19
  • Blank screen >>> Add error reporting to the top of your file(s) right after your opening PHP tag for example ` – Funk Forty Niner Mar 14 '15 at 00:44
  • possible duplicate of [How to get useful error messages in PHP?](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) – Sammitch Mar 14 '15 at 00:51
  • what do you want to get from this query > mysqli_query($db, "SELECT * from Articles"); – Joe Kdw Mar 14 '15 at 00:53

2 Answers2

3

It looks like you're missing a } at the end of your else statement

cchapman
  • 3,269
  • 10
  • 50
  • 68
0

cchapman990 is correct. I'd recommend reviewing your PHP error settings though, as they seem to be suppressed and seeing errors will make debugging a lot easier.

<?php
error_reporting( E_ERROR | E_WARNING | E_PARSE );
display_errors( 1 );
//etc.
?>

This can also be set globally within your php.ini file.

Benco
  • 130
  • 9