Jump to content

Archived

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

Bisa

Problem finding my error

Recommended Posts

Hi, i figured since I started learning php yesterday im still a newb [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] thus posting in here and not in "php Help".

well, to the problem.

Below is my "savenews.php" a file the user is directed to when trying to add a news item on the blog-site im working with.

[code]Parse error: syntax error, unexpected T_EXIT in savenews.php on line 14[/code]

Is all i get when trying to save my news :( If I remove the if (!mysql_query($sql,$con) and the next line all I get is the Success message but nothing is added to mysql database.

could any1 help me spot the problem?

[code]<?php

include ("databaseconnection.php");    //Connection with the mysql-server.

mysql_select_db("blog", $con);        //Select database to work with.

$date = date('Y-m-d H:i:s');        //Assign time/date.

$sql="INSERT INTO news (subject, text, date) VALUES

('".mysql_real_escape_string($_POST['subject'])."', '".mysql_real_escape_string($_POST['text'])."', '".$date."')";        //Insert subject, text and date into the table news.

if (!mysql_query($sql,$con)
    die('Error: ' . mysql_error());

echo "Success!";

?>[/code]

Share this post


Link to post
Share on other sites
You forgot to put a closing '[b])[/b]' bracket on this line:
[code]if (!mysql_query($sql,$con)[/code] if you add an ) at the end of that line it should sort out your error.

Share this post


Link to post
Share on other sites
Ah =) you got to love the n00b-iness of that [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

thnx for the help, it sorted my problem (but creating another1, but thats another story)

Share this post


Link to post
Share on other sites

×

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.