Click here to Skip to main content
14,484,846 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am new OOP PHP learner.I just wanted to create a table and insert my posts.Then I've faced Parse error above.

What I have tried:

include "db.php";
include "config.php";

$db = new database();

if (isset($_POST['submit'])){
	$title = $_POST['title'];
	$content = $_POST['content'];
$query = "INSERT INTO posts(title,content) VALUES('$title',$content')"




<!DOCTYPE html>


<form action="insert_post.php" method="post" enctype="multipart/form-data">
	<div class="form-group">
	<center><table width="800" align="center" border="2">
		<tr bgcolor="orange">
		<td colspan="6"><h1 style="text-align:center">Post EDIT</h1></td>
			<td align="right" bgcolor="orange">Post title:</td>
			<td><input type="text" name="title" size="60"></td>
			<td align="right" bgcolor="orange">Post Content:</td>
			<td><textarea name="Content" rows="15" cols="40"></textarea></td>

	<td colspan="6" align="center" bgcolor="orange"><input type="Submit" name="submit" value="Publish Now"  /></td>


Updated 4-Jan-20 9:44am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

There is no semicolon at the end of the previous line:
$query = "INSERT INTO posts(title,content) VALUES('$title',$content')";
//                                       This is missing in your code ^
See also PHP: Instruction separation - Manual[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100