Jump to content

Blogging Application PHP


DamoMoran

Recommended Posts

Hey guys, Trying to set up a blogging application using php and MySQL. Have the form set up to collect the information but simply isn't working when I launch it on the browser. Just want a simple way of storing the blog that the user enters into a DB that I have set up. Having trouble with it and is returning "unexpected T_VARIABLE" on line 34. Anyway hope someone can help. Thanks for the time :) Here's my code so far. <?php include ("top_part.php"); ?><?php include ("navi_part.php"); ?> <div id="content"> <?php // Check if form has been submitted and if blankif(isset($_POST['submit']) && !empty($_POST['Title']) && !empty($_POST['Author']) && !empty($_POST['Body'])){//storing the details entered into blog_ variables$blog_title = $_POST['Title'];$blog_body = $_POST['Body'];$blog_author = $_POST['Author'];$created = date ("Y-m-d H:i:s");$modified = date ("Y-m-d H:i:s"); // Database connection details$username = "mydb33836";$password = "mydb3383681";$server = "danu.it.nuigalway.ie";$database = "mydb33836"; //Connect to DBmysql_connect($server, $username, $password); //open the specific databasemysql_select_db($database) or die ("Unable to select database");s //blank first value leaves ID field empty. Therefore auto incriment can occur.$query = "INSERT INTO blogs VALUES ('', '$Title', '$Body', '$Author', '$created', '$modified')"; $result = mysql_query($query); //$recent_blogs = "SELECT id, title FROM blogs WHERE created = 0, 10 DESC"; // Close MySQL Connectionmysql_close(); // Echo response to userecho('<h2>Congrats</h2><p>You entered a Blog.</p>')}else { ?> <h2>The Blog</h2> <form name="blog" method="post" action=""> Title:<br><input type="varchar" size="30" name="Title"> <br><br> Blog:<br><textarea rows="20" cols="40" name="Body"></textarea> <br><br> Author:<br><input type="varchar" size="60" name="Author"> <br><br> <input type="submit" name="submit" value="Submit Blog"> </form> <?php } ?> </div> <?php include ("bottom_part.php"); ?> __________________________________________________________ Also here's a link to my mock website that i have been working on in class if thats any help. Thanks again, Damien.

Link to comment
Share on other sites

the error means there is a variable where it not supposed ti be

mysql_select_db($database) or die ("Unable to select database");s
remove the 's' here
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...