File: test_comment.php

Recommend this page to a friend!
  Classes of Peter Klauer  >  Comment  >  test_comment.php  >  Download  
File: test_comment.php
Role: Example script
Content type: text/plain
Description: How to implement the comment class
Class: Comment
Manage a comment system using an SQL database
Author: By
Last change:
Date: 14 years ago
Size: 3,121 bytes


Class file image Download
<head><title>Comment class example using mysql</title>


include '../includes/class_comment.php';

# ... connect here to your sql server
$sqlconnection = mysql_connect('myserver','myusername','mypassword');
if (!
$sqlconnection) { die('Could not connect: ' . mysql_error()); }

$sqltable = new sqltable( );
$sqltable->SQLTYPE = 'mysql';


# $id_for and $code_for are the arguments.
# $sqltable is the table from above
# the empty string is the path to the css directory
# NOTE: $code_for is never allowed to have more than 8 characters.

$comment = new comment(0,'example',$sqltable, '../' );
$comment->SQLTYPE = 'mysql';

# install() will create the "comments" sql table under normal conditions and mysql.
# it will fail normally under mssql. Just copy the text from the mssql_query() of
# the install() function into your SQL Query Analyzer if the following install() fails.
# And then execute it with administrators rights. Don't forget to give
# the correct privileges to the freshly created table "comments"

$comment->install(); // Preparing, checking for sql table "comments", writing cssfile if not existing



<h1>This is an example</h1>
This is some simple page which can be commented.
If the script is showing this text, then the comment class is properly installed.

And here may come some comments, which may be re-edited by the author as long
as the internet connection does not change.


<div align=center><div style="text-align:left;width:80%;margin:0 auto">


# some optional options:

# $comment->debug = false; //true; // show additional info if true

# maybe we put some finedivs around the comment parts? (package ...)
# $comment->before_insert = $roundinput2->gettop(); // for example only, the finediv class is not initiated in this script
# $comment->after_insert = $roundinput2->getbottom();
# $comment->before_comments = $finediv->gettop();
# $comment->after_comments = $finediv->getbottom();

# $comment->showcomments = true; // Show the comments from start, don't wait on a mouseclick.

# $comment->prevent_multiple = false; // true by default

# $comment->prevent_spam = false; // allow links? Is true by default and changes input to $say_nolinks if a link is found

# to use in other languages, you may like to change
# all the "say_xxxx" text strings here like so for German text:

  $comment->say_comment = 'Kommentar:<br><img src="images/writing2.gif" alt="Hand hält Feder">';
  $comment->say_comments = 'Kommentare';
  $comment->say_addcomment = 'Einen Kommentar hinzufügen';
  $comment->say_submit = 'Abschicken';
  $comment->say_nickname = 'Name/Alias:';
  $comment->say_update = 'Ändern';
  $comment->say_updated = 'Eintrag geändert.';
  $comment->say_close = 'Schließen (X)';



For more information send a message to info at phpclasses dot org.