ericlin
Hi, I'm trying to put a guestbook in a dokuwiki page, so that everyone can leave me a message.
I download a php guestbook. I don't have problem to execut it using an external link(but this will
be in a new window, which is not what I want)
But when I tried to put it in an existing dokuwiki page using:
<php>
include("guest.php");
</php>
I got the following error:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /homepages/45/d184410608/htdocs/lib/tpl/sidebar/main.php:3) in /homepages/45/d184410608/htdocs/guest.php on line 90
Does anyone know what I should do ? Thanks.
purplepaisley
It sounds like you need to include your php file before any page content output. Perhaps the very first line of lib/tpl/default/main.php. If it still gives you an error, I would try it as the first line of doku.php.
I'm using "My Two Cents" in a similar way for comments. Works well within Dokuwiki templates but requires mysql.
http://wiki.splitbrain.org/sw:my_two_cents?s=two%20cents
Hope that helps.
ericlin
Hi, Thanks for your reply.
I tried "My Two Cents" and got:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /homepages/45/d184410608/htdocs/t2/mtc.class.php on line 95
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /homepages/45/d184410608/htdocs/t2/mtc.class.php on line 98
Do you know why I got those errors ? Sorry I don't know much about php.
Thanks
Eric
zyberdog
Just as another option, I wanted to mention the
Discussion plugin. Instead of using it for a discussion section below each page, you could set up a single
wiki:guestbook page with
~~DISCUSSION~~ whilst turned off everywhere else.
As far as I can tell from your first post it would do what you are after.
ericlin
zyberdog, Thanks for your reply. I tried the Discussion plugin. However 2 problems bother me. (1) It does not have the spam preventing feature. (2) Looks like if I install the sidebar template, the discussion will not work. Thanks again for your reply and any other replies you may make. :)
purplepaisley
I'm not sure why you have the mysql errors. Did you run the sql query to setup your tables for MTC?
ericlin
Purplepaisley, Thanks for your reply. What I did was (1)using panel of my hosting service to create mySQL database. (2) Modify mtc.class.php for these variables: $db_host, $db_user,$db_pass,$db_name Is there anything else I need to do ? Thanks again.
purplepaisley
Yes, you need to run a mysql query that is contained in the db.sql file in the download package. PHPmyadmin is handy for this, it may be within your hosting control panel, in the Mysql section.
ericlin
Purplepaisley, I found PHPmyadmin but don't know how to "run a mysql query". I can see some options here: "Server Choice", "My SQL (Export)", "phpMyAdmin(Language)", "phpMyAdmin documentation","Offical phpMyAdminHomepage" Could you tell me how to do it ? Thanks again.
ericlin
Oh, I also found if I click on the db at left hand side, I got "Create new table on database db....." Name: _____ Number of fields: ___ Is this what I should do ? What data should I fill in ? Thanks
purplepaisley
When you click on the database that you created on the left, you should have a tab on the right for an SQL query? Mine is "Query". On this page, there should be a box labeled "SQL query on database xxxx", just paste the contents of the db.sql into that box and click Submit query.
ericlin
that's what I got: :(
MySQL said:
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci' at line 1
purplepaisley
Sorry, I forgot about the first line. No need to create a database because you've already done that. Paste from the line that starts with "CREATE TABLE...."
ericlin
Purplepaisley, Again, thanks for your help. I've (I guess) successfully created table "mtc_comments' (after I removed "CHARACTER SET utf8 COLLATE utf8_general_ci". So, it looks good now. I can see a form waiting for me to input data. However, when I tried to leave a message, it doesn't seem to work. It doesn't report any error or warning, but it also did not show the messages I just typed.
Question: Is it right thing to write the code like this: (at the start page)
<php>
require_once('mtc.class.php');
$MTC = new MTC();
$MTC->init();
$MTC->comment_form();
$MTC->comments();
</php>
Thank you one million times !!
purplepaisley
No problem. You're doing well considering my instructions are half wrong, I must have been tired last night, sorry.
Check to see if your comments have been added to the database in phpmyadmin. If you choose your new database, you should see a list of the tables, click the mtc one. Then there should be a browse tab on the right. When you click that, it will list the rows in your table. Are there any? If yes, what is in the "url" field of this one that is not displaying?
ericlin
Purplepaisly, I know I have used this word to often, but this is the only one I can think of: thank you.
I checked the table using phpMyAdmin, and found: Space usage: data 0 bytes, index: 1024 bytes.
Looks likely the data has not been entered. Do you have any suggestion ? again, thank you.
purplepaisley
If it were me, I'd create a test php page (such as commenttest.php), add the mtc code to that and try it outside the dokuwiki and see if it works on it's own.
ericlin
I created commenttest.php , which is:
<?php
require_once('mtc.class.php');
$MTC = new MTC();
$MTC->init();
$MTC->comments();
$MTC->comment_form();
?>
and execute it this way: www.mydomain.com/commenttest.php , the result is the same : the input form shows, no error messages, no data entered. .. At least I know it's not dokuwiki's problem ..... Thanks
ericlin
Hi, I spend some effort and found (1) using a separate php fiile works perfectly(I made a mistake before) (2)it does not work in dokuwiki, I traced to this line of code which does not work as that in (1) :
if($_POST[MTC]['do'] == 'add'){
$this->_add_comment();
}else if($_POST[MTC]['do'] == 'del'){
$this->_del_comment();
}
The result of $_POST[MTC]['do'] seems to be NULL. Do you have idea why it does not work in my dokuwiki ? Thanks
purplepaisley
I wouldn't know, sorry. I have mine working differently to you. Instead of including it in the wiki content, I have included it within the template.