Help!, Php & Mysql problem |
Help!, Php & Mysql problem |
![]()
Post
#1
|
|
Newbie ![]() Group: Member Posts: 8 Joined: Nov 2007 Member No: 592,112 ![]() |
So my code is:
CODE <?php // Acquire Settings require_once('../includes/DbConnector.php'); // Check whether a form has been submitted. If so, carry on if ($HTTP_POST_VARS){ // Create a new instance of DbConnector $connector = new DbConnector(); // Form Validation // Create an SQL query $insertQuery = "INSERT INTO articles (article_title,author_name,category,article_text) VALUES (". "'".$HTTP_POST_VARS['article_title']."', ". "'".$HTTP_POST_VARS['author_name']."', ". $HTTP_POST_VARS['category'].", ". "'".$HTTP_POST_VARS['article_text']."') // Insert the data obtained from the form into the databse if ($result = $connector->query($insertQuery)){ // If it worked then... echo '<center><b>Article added to the database</b></center><br>'; }else{ // If it hasn't worked... exit('<center>Sorry, there was an error in saving to the database.</center>'); } include '../html/forms/news_insert_form.html'; ?> The error- Parse error: syntax error, unexpected $end in _____ on line 35 How can i fix that? |
|
|
![]() |
![]()
Post
#2
|
|
![]() This bag is not a toy. ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Staff Alumni Posts: 3,090 Joined: Oct 2007 Member No: 583,108 ![]() |
If it helps, line 35 is where your document ends:
?> It may be a problem with the line before that, the include statement. What happens if you take it out? I think it would help if I had more information. What type of site is this for (what type of content management system, etc.)? Would you mind posting a link? |
|
|
![]()
Post
#3
|
|
![]() i did your boyfriend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Designer Posts: 3,335 Joined: Feb 2004 Member No: 4,071 ![]() |
that error usually means you are missing a } somewhere.
|
|
|
![]()
Post
#4
|
|
![]() This bag is not a toy. ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Staff Alumni Posts: 3,090 Joined: Oct 2007 Member No: 583,108 ![]() |
I actually just got a chance to really look over it, and it does appear that you have three open brackets and only two "closed" brackets.
In the first part of the code, you have this: // Check whether a form has been submitted. If so, carry on if ($HTTP_POST_VARS){ This statement never ends because you never closed it off. If you want everything that comes after that to depend upon that statement (whether or not a form has been submitted) you'll need to add a bracket at the end; otherwise just figure out where you were trying to go with that. |
|
|
![]() ![]() |