Jump to content

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 post
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 Edited by birbal
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...