You are here:  » Small error im getting


Small error im getting

Submitted by getgood on Wed, 2006-04-26 17:50 in

Hi Dave,

Im just installing the latest script onto my website and have been playing around woth the reviews template..

Im getting a small error when I submit a review - Warning: Cannot modify header information - headers already sent by (output started at /home/golf/public_html/search1/reviews.php:1) in /home/golf/public_html/search1/reviews.php on line 376
-

Im calling the product name through a

<?php
 
print "$q"
?>
tag in at the top of the page?...not sure if this is conflicting with the process of the header refreshing or something on submit?

The reviews are going to the admin area as submitted but the user will see the error and think there's a problem,

Please can you take a quick look when you get a second and let me know heta it might be - http://www.thebiggolfstore.com/search1/review/Maxfli-Black-Max-Golf-Balls.html -

Just another quick question...how can I delete the reviews Iive submitted as a test? Ive gone into php myadmin and emptied the table for reviews which deletes them...but on the search results page and end product page it says 9 reviews...then on the reviews page 0?

Will I have to delete the data feeds and start again to clear the memory or is there a quick fix?

Cheers
Adam

Submitted by support on Wed, 2006-04-26 18:06

Hi Adam.

Yes - when a review is submitted it is loaded into the database and then the page is refreshed to avoid the review being submitted multiple times.

The refresh is performed using the header() function; and as you can see from the error message this is not possible if you have already generated some HTML. You would need to remove the section of code that handles the review form submission into your containing code so that it is right at the top. The relevant code is as follows; at the top of reviews.php

<?php
  
if (isset($_POST["submit"]))
  {
    if (!isset(
$_POST["comments"])) $_POST["comments"] = "";
    
$sql "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='0',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";
    
database_queryModify($sql,$insertId);
    
header("Location: ".$_SERVER["REQUEST_URI"]."?pending=1");
    exit();
  }
?>

...make sure that comes right at the top and it should then work.

With regards deleting reviews; the reason simply emptying the reviews table doesn't remove the review count and product rating is because these are written into the products table, and they're only updated when you either moderate reviews; or import a feed.

To reset reviews, the easiest way would be to:

i) Empty the reviews table (using PHPMyAdmin)
ii) Add a test review
iii) Moderate and reject the test review

Everything should then be reset.

Hope this helps!

Submitted by getgood on Wed, 2006-04-26 18:31

Hi Dave,

Your help works like a charm as usual...

Say...I was wandering whether you had considered setting up an affiliate program for this script yet? I have a few potential future projects which your script will fit into very well...

Let me know

Thanks again

Adam