Jump to content


Photo

Problem finding my error


  • Please log in to reply
2 replies to this topic

#1 Bisa

Bisa
  • Members
  • PipPipPip
  • Advanced Member
  • 76 posts
  • LocationSweden

Posted 25 May 2006 - 08:17 AM

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.

Parse error: syntax error, unexpected T_EXIT in savenews.php on line 14

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?

<?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!";

?>



#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 May 2006 - 08:30 AM

You forgot to put a closing ')' bracket on this line:
if (!mysql_query($sql,$con)
if you add an ) at the end of that line it should sort out your error.

#3 Bisa

Bisa
  • Members
  • PipPipPip
  • Advanced Member
  • 76 posts
  • LocationSweden

Posted 25 May 2006 - 08:40 AM

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)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users