Troubleshooting and FAQ

sNews and the .htaccess file - An Important Relationship

The .htaccess file is often a source of installation problems in relation with sNews.

sNews uses the .htaccess file to execute certain behaviours through Apache. To do this the .htaccess file must be in your site's root directory and it must be named exactly as it is: .htaccess. On top of that your site must be on a host server that has all the right conditions present to function properly.

In some cases, you may find that you cannot get the .htaccess file working in your site. This is not an sNews issue or bug. The problem always exists on your host's server.

go up

Why sNews .htaccess files won't work on some servers:

Apache's mod_rewrite module is not enabled.
Some hosts choose not to enable the mod_rewrite module within their Apache's server configuration file. Their reason may be security-related, in that they don't want any of their clients creating and using .htaccess files that could cause a security breakdown on their servers. If this is the case, you have no choice but to find another host who does have this module enabled so you can use your own .htaccess files without restriction.

Apache's mod_rewrite module is enabled but your site still doesn't work.
Some hosts will have the mod_rewrite module enabled but they also put hidden .htaccess files on every client's domain root directory and this file is 'write-protected' so you cannot overwrite it with your own .htaccess file. If you have uploaded your .htaccess file and noticed that it was visible on your domain's root directory right after uploading..., but seemed to disappear shortly afterwards..., then you have experienced this condition. A host will do this so they can have more control over security by using .htaccess files to keep you from using them. If your host will not remove their .htaccess file from your domain root then you have no choice but to find a better host.

Do not create Login Firewalls with CPanel. If you created a security login firewall on your domain using your domain's CPanel, that will cause the same problem. When you use this feature in your CPanel, you may not realize that it creates an .htaccess file in your root directory. It might be visible or it might be hidden. In all cases, files created this way are also write-protected so the login firewall cannot be eliminated by over-writing the file. The only way you can remove this file is by logging back into your CPanel, and de-activating it from there. Once this is done, you should be able to upload your .htaccess file.

Apache does not read .htaccess files by default even when the mod_rewrite module is installed.

When you have this error message when you click a link (except "Home"):

Not Found
The requested URL /***/snews/archives/ was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an Error Document to handle the request.
Apache/1.3.34 Server ad mydomain.com Post 80.

the problem probably lies in your webserver.

The reason for this is an option inside the default Apache installation.
If you have access to your Apache installation find the main configuration file httpd.conf; it's default location is /usr/local/apachex/conf/httpd.conf, but it may be moved using run-time or compile-time configuration. Find:

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

Change this to:

<Directory />
  Options FollowSymLinks
  AllowOverride All
</Directory>

Then restart Apache.

Now if you have other websites that are on the same server, you can add 'per directory' options.

<Directory /var/www/html/mysite.com/snews_directory/>
  Options FollowSymLinks
  AllowOverride All
</Directory>

Restart Apache, and then you should be set.

go up

Why doesn't .htaccess work on a Microsft IIS server?

The following, from hypergurl.com explains how .htaccess files work with the Apache server, and offers a solution for MS IIS servers.

The mod_rewrite module is a powerful scripting program that will translate URL's based on the patterns that you define. In layman's terms, this will allow you to feed the search engines URL's that appear to be static, but are actually dynamic.

As an example, consider the dynamic URL: http://www.yourWeb site.com/yourscript.php?id=123. This URL passes the variable called "id" to a script called yourscript.php. This script builds a dynamic page based on the product ID. How can we make this more search engine friendly?

With mod-rewrite, you can get the same result using the following URL: http://www.yourWeb site.com/productid123.htm. Notice how the "offending" question mark symbol has been removed from the URL. This second URL is much more search engine friendly. In addition, by using the mod-rewrite technique, it will function exactly the same as the first URL.

When mod-rewrite sees "productid123.htm", it knows to translate that into "yourscript.php?id=123". This translation takes place behind the scenes, so the URL in the browser's address bar will continue to display "productid123.htm" while your database program sees the URL it is expecting to see. It is important to understand that there is no re-direction taking place. It's simply a URL translation.

Is there an alternative to .htaccess for MS IIS servers? Yes..., there is. If your Web site runs on the Microsoft IIS server, you can obtain the same basic functionality described for Apache Web sites using a program called ISAPI rewrite. You can learn more about this program by visiting the website of the makers of this program.

Summary

Whether you are running a Microsoft or Apache server, test your changes by browsing and searching your site to see if it worked. Instead of having URL's containing question marks followed by the article or page ID, the ID should become part of the article or page name. Ampersands and commas should also be eliminated whenever possible. Hyphens, underscores, and periods should be fine.

Once you have verified that the change worked as expected, you must go into your site and change the URL's that point to each of your article or category pages so that they conform to the new format. This is critical since these are the links that the search engines will follow to find your product pages. If you leave them using the old syntax containing the troublesome symbols, then the search engines may still avoid spidering the links.

go up

error: Home Page with no CSS styling and clicking a link gives a Error 404 Page not found

Probable cause

The website variable setting in snews.php is not correct. It may be missing a folder name or the forward slash is missing.

Possible solutions

check to ensure your website URL is complete and the forward slash is in place at the end, like:

$db['website'] = 'http://www.your-domain.com/';

If your site is in a separate folder in the server's root directory, the URL needs the folder name in it too, like:

$db['website'] = 'http://your-domain.com/snews-folder-name/';

go up

error message: Object not found! Error 404:

Your site's Home Page displays, but you get this message when you click on any link on this page.

Probable Cause

The 'RewriteEngine On' line is missing or not enabled in your .htaccess file. Or, your .htaccess file is not active, present, or not working at all.

Possible Solution

Check to see that your .htaccess file is located in your sNews site's root directory or folder, and that the 'RewriteEngine On' line is present and enabled:

OK:
RewriteEngine On
Not OK:
#RewriteEngine On -or- RewriteEngine Off

go up

error message: There was an error while connecting to the database.

Probable Cause

The variable settings in snews.php relating to the database are not correct.

Solution

Check to make sure the settings are exactly the same as you gave your database when you created it, e.g.:

$db['dbhost'] = 'localhost'; //MySQL Host
$db['dbname'] = 'snews15'; //Database Name
$db['dbuname'] = 'your_username'; //Database Username
$db['dbpass'] = 'your_passw'; //Database password

go up

error message: Warning: mysql_connect(): Access denied for user: 'your username@localhost' (Using password: YES) in c:xamppxampphtdocssnews15snews.php on line ....

Probable cause

Either your database username or database password are incorrect.

Solution

Check to make sure the settings are exactly the same as you gave your database when you created it, e.g.:

$db['dbuname'] = 'your_username'; //Database Username
$db['dbpass'] = 'your_passw'; //Database password

go up

error message: Warning: mysql_connect(): Unknown MySQL Server Host 'some_text' (1) in c:xamppxampphtdocssnews15snews.php on line ....

Possible cause

The dbhost variable setting in snews.php is not correct.

Solution

Check the dbhost variable setting in snews.php; in most cases this should be 'localhost'

$db['dbhost'] = 'localhost'; //MySQL Host

go up

error message: Warning: Cannot modify header information - headers already sent by...

Probale cause

  1. This can be caused by having white space before or after the opening and closing PHP tags in a php file.
  2. It can also be caused by incorrect character encoding of the index.php file. UTF-8 encoding with BOM e.g. is incorrect.

Solution

  1. Check the php file that you have recently changed to ensure there is no space at the top of the file before the opening tag <?php and that there is no space after the closing tag ?>.
  2. Save the index.php file with ANSI encoding. If UTF-8 is the preffered choice, the file needs to be saved as UTF-8 without BOM.

go up

Warning: mysql_fetch_array(): ...

You get one, two, three or more warning lines in your Home page that all point to different line numbers in the snews.php file... e.g.:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:xamppxampphtdocssnews15snews.php on line 1684

Probable Cause

This usually happens when a query within a particular function (in snews.php) cannot find the data it is looking for in the database. When you get several messages pointing to several lines within the snews.php file, that means there are several queries (possibly in several functions) that cannot find their data in the database.

The problem could be that

  1. the database is corrupt or not compatible with your installation (dbase for the wrong version of sNews)
  2. the table-names are incorrect
  3. the tables are not prefixed properly.

Possible solutions

  1. If you have been saving back-ups of your database on a regular schedule, try restoring your database with your latest backup.
  2. If you upgraded your sNews files to a newer version but did not update the database as well, you may need to delete your dbase tables and create the new ones for your sNews version.
  3. If you have added a prefix to your table-names in the database, you also need to make sure you have added that to the prefix variable in snews.php:

$db['prefix'] = 'snews_'; //Database prefix

go up

error message: Internal Server error!

Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the server administrator at .....

Possible solution

You better contact your hosting provider about this error. More information about this error may be available in the server error log.

go up

error message: Internal Server error! ERROR 500

Probable Cause

You have added a string to the .htaccess file that interrupts the parsing sequence of the default sNews directives in the file. Or, something has changed that is affecting an existing directive.

Possible Solution

Remove the offending string(s) or refresh the file with a new default copy of the .htaccess file.

go up

error message: Error 500 - Internal Server Error

If you have set everything up correctly and you have checked you can use your own .htaccess files on your server ànd have mod_rewrite enabled ànd you still get this error, then:

Probable cause

maybe the following section of the .htaccess file is not allowed on your web host server:

<IfModule mod_php4.c>
    php_value session.use_trans_sid 0
</IfModule>

Possible solution

Try amending the top of the .htaccess file to this:

#<IfModule mod_php4.c>
#    php_value session.use_trans_sid 0
#</IfModule>

Add a # to the first 3 lines of code.

Also, if you have just installed XAMPP make sure that the 'mod_rewrite' module is enabled in Apache's httpd.conf file. You can check to see if it is in the enabled modules list by running clicking the phpinfo() link in the bottom of the first section in the left side-bar after opening the main xampp page at http://localhost/xampp/index.php. By default, it is not enabled when XAMPP is first installed.

go up

error message: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in (url) on line (number)

Probable cause

Some WYSIWYG editors like Dreamweaver, MS Word, Frontpage or similar editors sometimes inject unwanted (and invisible) code into your files. When you edited your snews.php with one of these, they might have corrupted your code.

Possible solution

Use a good text editor. Tips on good text editors for the big OS's can be found in the Tools area.

go up

error message: Warning: session_start():

Cannot send session cache limiter - headers already sent (output started at /home/xxxxxx/public_html/test/inside_test.php:1) in /home/xxxxxx/public_html/test/inside_test.php on line 1

Possible solution

If your default charset (admin > settings > time and local settings) is UTF-8, then your index.file needs to be saved without BOM.

go up

No CSS-styling apart from the Homepage.

You probably have not used the <?php title(); ?>-function in your index.php file.
Change in your index.php

<title>Your Title</title>

in

<?php title(); ?>.

Beware that the title function (located in snews.php) prints a base href in your index.php. That base href is the site URL you have filled in in snews.php ($db['website'] = http://www.yoursite.ext/;), so you can use relative URL's, like "style.css" for your stylesheet.

go up

How do I make a list in an article?

In the stylesheet style.css which comes with the snews standard package you will find:

li {list-style-type: none} /* remove all the style elements from li */

This is to prevent bulleting when used in menus and the like. Now create a class to style your lists to use in articles, for instance:

/* make a class for li (just an example) */
.list li {
  margin:.5em 0 0 0;
  padding:0 0 0 15px;
  list-style:none;
  background: url(../images/list1.gif) no-repeat;
  background-position: 0 .3em;
}

go up

The textarea of the article edit panel runs right into the third column of my template.
Both my email - and my comment text field come out tiny.

The default stylesheet style.css that comes with the standard sNews package has some styles defined, so you need to copy these styles into the CSS file of any template you port to run with sNews. These are the ones that style the administration panels. You can copy from here and paste into the bottom of your template's CSS file:

/* SNEWS */
fieldset { border: 1px solid #ccc; padding: 10px 8px; margin: 0 0 8px 0; background: #E6FFE4; color: #000; }
input { padding: 3px; margin: 0; }
textarea { width: 97%; height: 20em; padding: 3px;}
input.search { border: 1px solid #ccc; padding: 4px; width: 160px; }
.comment { background: #eee; color: #808080; padding: 10px; margin: 0 0 10px 0; border-top: 1px solid #ccc; }
.commentsbox { background: #E8FFD9; color: #808080; padding: 10px; margin: 0 0 10px 0; border-top: 1px solid #ccc; }.

go up

How to style my images in articles

Put this in your CSS stylesheet:

img {border:0; margin: 0; padding: 0;}

Then just make a class, for example:

.imgLeft {clear:left; float: left; margin: 5px 10px 5px 0;}

The html in your article will look like this:

<img src="img/your_image.gif" alt="your_alt" title="your_title" class="imgLeft" />.

go up

How to style the comments- and infoline

In snews.php there is a function called tags (around line 250) which allows you to easily style your comments and infoline.

$tags['comments'] = '<div class="comment">,<p class="date">,name, on ,date,edit,</p>,<p>,comment,<p>,</div>';

For example we want the commentator's name in bold; then just change the tag to:

$tags['comments'] = '<div class="comment">,<p class="date">,<strong>,name,</strong>, on ,date,edit,</p>,<p>,comment,<p>,</div>';

Or insert a div or anything you like. But beware that you separate the individual elements by a comma, with no spaces, unless you actually want a space on that place.

go up

How do I style the Comments Area?

You can find an excellent tutorial about this subject here.

go up

No RSS-logo in the address bar

Put this line in the head of your index.php:

<link rel="alternate" type="applications/rss+xml" title="RSS 2.0" href="rss/">

You can also add a "manual" link to your index.php, like this

<a href="rss/" title="RSS Feed" accesskey="r">RSS Feed</a> OR
<a href="rss/" title="RSS Feed" accesskey="r"><img src="rss-logo.gif" alt="RSS-link" title="Link to my RSS-feeds" /></a>

go up

RSS-error: Error interpreting XML: not well formed, line 1, column 103

XML has 5 predefined Character Entities:

character: < encoding: &lt; OR &#60;
character: > encoding: &gt OR &#62;
character: & encoding: &amp; OR &#38;
character: ' encoding: &apos; OR &#39;
character: " encoding: &quot; OR &#34;

The rest of the special characters can be handled using either UTF-8 (optimal/best solution) or by using decimal or hexadecimal entities (make sure you convert Windows characters). The most made error is probably the one with the ampersand character ’&’ and the fact that people don't realize that it is important to use the proper encoding.

Just be aware that when using UTF-8, the source of snews.php needs to be saved as UTF-8 with no BOM, and all your HTML pages must be in the same character set. So make sure that:

  1. your editor uses UTF-8 when creating/editing documents (some editors default to the "automatic" character set encoding that your system language uses);
  2. the character set in your snews.php as well as index.php is set to UTF-8, and
  3. the admin interface (Admin » Settings » Time and Locale settings), that the default character set is set to UTF-8.

You can validate your site at: http://feedvalidator.org/

You will find more about XML entities here and here.

go up

My RSS feed is empty

Your RSS feed is probably not valid. You can validate your site at: http://feedvalidator.org/

go up

Normal formatting (bold, italic, lists) and Links in the articles, are not being passed to the newsreaders.

Find in snews.php the function RSS() and search for the line:

$description = preg_replace("[[(.*?)]]", "", stripslashes(strip_tags($r['text'])));

and replace that with:

$description = preg_replace("[[(.*?)]]", "", stripslashes($r['text']));

then find a couple of lines below:

$item .= '<description>'.$description.'</description>';

and replace that line with:

$item .= '<description><![CDATA['.$description.']]></description>';

go up

Can I call static HTML-pages in sNews

Make a page in sNews with the same name as the HTML-page and include it in the page as follows:

[include]http://yourdomain/path/to/htmlpage.html[/include]

go up

I cannot upload any files

You have to be sure that your upload directory is world wide writable, so if this is not the case, then chmod this folder to 777

For security reasons be carefull with this. There is a MOD to restrict upload of certain file types in the MOD's section.

go up

How do I use chmod in a FTP client?

To chmod a file:

  1. Connect to the server with your FTP-cliënt;
  2. Select the file to highlight it;
  3. Right-click the file and choose "chmod (UNIX)" (Depending on your FTP client, this may also be labelled something like "File Attributes" or "File Permissions");
  4. You will get a new window with checkboxes grouped by the type of permission as rows and the who gets that permission as columns, very similar to the grid shown in the cPanel File Manager. Fill in the checkboxes the same way as described above. The window may or may not show you the resulting numbers, depending on your own client software;
  5. Click "OK"

go up

I don't get the 'Read more ...' link

There are two possible reasons.

  1. You did not used the [break] command in your article. This BBcode tells sNews where to cut off your article and add the 'Read more ...'-link
    When editing an article in the administration panel you will find the Break-button at the bottom of the textarea.
  2. In the administration panel under label 'Customize' you did not ticked the 'Display info line (read more/ comments/ date)'-checkbox.

Also when you use the command the title of your article will become a link to show the full article.

How to make the article titles show up as links

See the question: "I don't get the 'Read more ...' link"

go up

I don't want the category 'Home'

In the administration panel under the label Site→Settings→Settings, you can change this in the input field 'Home SEF (used as link to Home):' to anything you want, e.g. to 'general'. In that case your link in the adresbar will look like this: http://your_domain.com/general/article.

go up

How can I remove 'Home' from the Category listing

Find the following line in the function categories() in snews.php

echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';

and simply comment this entire line so it looks like:

// echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';

go up

GET STARTED

sNews requires PHP, MySQL and mod rewrite. If your server meets those requirements, get started and learn how to install sNews on your website in 3 easy steps.

LEARN

Browse through our help center and learn about template tags and how to simply create your own theme. Dig into sNews and customize it to behave the way you want.

EXTEND

sNews can be a simple blog tool and a full blown CMS. Customize it with addons, mods or play with different themes.

DISCUSS

Talk about sNews on our Forum and share your expirience.