Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-06-2008, 07:25 AM
lars55 lars55 is offline
Registered User
 
Join Date: Nov 2008
Location: Eureka Springs, AR
Posts: 1
Exclamation Premature end of script headers: newArticle.php

I got to tutorial 3 and have tried to implement it to that point. When I try to post a new article, I get the dreaded Internal Server Error 500 "Premature end of script headers: newArticle.php". I have checked and rechecked my coding and can't find where the problem might be.

I checked my permissions on the php scripts, all are set to 755. The message tells me the problem is somewhere in or around the newArticle.php file. Here is the code for said file below.

<?php
// Get the PHP file containing the DbConnector class
require_once('../includes/DbConnector.php');

// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){

// Create an instance of DbConnector
$connector = new DbConnector();

// IMPORTANT!! ADD FORM VALIDATION CODE HERE - SEE THE NEXT ARTICLE

// Create an SQL query (MySQL version)
$insertQuery = "INSERT INTO articles (title,tagline,section,article) VALUES (".
"'".$HTTP_POST_VARS['title']."', ".
"'".$HTTP_POST_VARS['tagline']."', ".
$HTTP_POST_VARS['section'].", ".
"'".$HTTP_POST_VARS['article']."')";

// Save the form data into the database
if ($result = $connector->query($insertQuery)){

// It worked, give confirmation
echo '<center><b>Article added to the database</b></center><br>';

}else{

// It hasn't worked so stop. Better error handling code would be good here!
exit('<center>Sorry, there was an error saving to the database</center>');

}

}
?>

If anyone sees a problem or has a suggestion, please advise.

thanks,
lars.
Reply With Quote
  #2 (permalink)  
Old 11-18-2008, 09:41 PM
marzar00 marzar00 is offline
Registered User
 
Join Date: Jun 2008
Posts: 22
G'day lars,

Try completing all of the articles and see if that helps. I noticed that in a few of the early code example, Peter has missed a few bits. It very well could have happened to his newArticle.php code that you have above. Rest assured that it DOES work...eventually!

Hope that helps,

Marzar
Reply With Quote
  #3 (permalink)  
Old 01-07-2009, 04:36 PM
Chip Chip is offline
Registered User
 
Join Date: Jan 2009
Location: Cardiff
Posts: 6
Hi Lars,
I can't remember if I had a problem with this or not but it looks like some of your quotations around the $insert function might be wrong?
It could just be the way it looks due to the forum/browser, but try this:

N.B. I will put extra spaces in just to be extra clear on which quotes to use, in practice you can remove them:
Instaed of this:
// Create an SQL query (MySQL version)
$insertQuery = "INSERT INTO articles (title,tagline,section,article) VALUES (".
"'".$HTTP_POST_VARS['title']."', ".
"'".$HTTP_POST_VARS['tagline']."', ".
$HTTP_POST_VARS['section'].", ".
"'".$HTTP_POST_VARS['article']."')";
try:
// Create an SQL query (MySQL version)
$insertQuery = "INSERT INTO articles (title,tagline,section,article) VALUES (' " .
$HTTP_POST_VARS['title']." ' , ' ".
$HTTP_POST_VARS['tagline']." ', ' ".
$HTTP_POST_VARS['section']." ', ' ".
$HTTP_POST_VARS['article']." ' )";

I appreciate that these differences are subtle and might not be easy to see, but look closely between the " and ' and hopefully you'll see a difference.
If you copy and paste that second version it might work?

Good luck

Chip
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 04:52 PM.





Acceptable Use Policy

WebMediaBrands

internet.comMediabistrojusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Shopping | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0