PHP Classes

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: 18 years ago
Size: 3,121 bytes
 

Contents

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

<?PHP

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

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

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

$sqltable->install();

# $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';

#
# MYSQL:
# install() will create the "comments" sql table under normal conditions and mysql.
#
# MSSQL:
# 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

?>

</head><body>

<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.
<BR>
<BR>
<big>Congratulations!</big>

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

<BR>
<BR>

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

<?php

#
# 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)';
*/

$comment->put();

?>
</div></div>
</body></html>