PDA

View Full Version : Creating a .php Template Instead of .html


Destroyer X
06-18-2004, 03:20 PM
Hey everyone! I have a question regarding template creation. You see, my Web site is composed of PHP pages, and as part of my Web site layout, I have a Website Poll on every page. Because I use a PH code to place my poll on every page of my layout, if I were to use a .html template for the search engine, I'm afraid that the page would be broken when I try to insert a PHP code into a .html page.

My question is, is there a possibility that instead of using a .html page for a template, would it be possible to use a .php page for a template? Thank you very much for your time.

Ciao for now!

Charter
06-18-2004, 05:47 PM
Hi. Check through this (http://www.phpdig.net/showthread.php?threadid=348) thread.

Destroyer X
06-20-2004, 10:34 PM
To prevent an inconvenience, I purposely made the text smaller.

Well, I managed to follow the directions that I found on that thread. However, I somehow managed to mess up in using my Web site template for the search pages. I'll try to be as descriptive as possible, so people can see exactly where I went wrong and hopefully offer a possible solution. First, http://www.destroyerx.net/staff.php is one of the pages of my new Web site layout that I'm working on. Here's the coding I used for search_function.php that was suggested to put in:

function get_my_includes($filename) {
if (file_exists($filename)) {
$buffer = "";
$handle = fopen($filename, "r");
while (!feof($handle)) {
$buffer .= fgets($handle, 4096);
}
fclose($handle);
return $buffer;
}
}

// check that the paths are correct or use full paths
$my_page_header = includes("/home/destroyerx/search/templates/destroyerx/header.php");
$my_page_sidebar = includes("/home/destroyerx/search/templates/destroyerx/sidebar.php");
$my_page_main = includes("/home/destroyerx/search/templates/destroyerx/main.php");
$my_page_footer = includes("/home/destroyerx/search/templates/destroyerx/footer.php");

if ($template == 'array' || is_file($template)) {
$phpdig_version = PHPDIG_VERSION;
$t_mstrings = compact('my_page_header','my_page_footer','powered_by_link','title_message'
,'phpdig_version','result_message','nav_bar','ignore_message','ignore_comme
ss','pages_bar','previous_link','next_link','templates_links');
$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'templ
ate',$template);
if ($template == 'array') {
return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
}
else {
$t_strings = array_merge($t_mstrings,$t_fstrings);
phpdigParseTemplate($template,$t_strings,$table_results);
}
}

In my "search/templates/destroyerx" folder, I made four includes: header.php, sidebar.php, main.php, and forum.php. Since the coding for each of them can be quite lenghty, I've saved them all as text files at

http://www.destroyerx.net/search/templates/destroyerx/header.txt

http://www.destroyerx.net/search/templates/destroyerx/sidebar.txt

http://www.destroyerx.net/search/templates/destroyerx/main.txt

http://www.destroyerx.net/search/templates/destroyerx/footer.txt

After I made the modifications to search_function.php, I then created destroyerx.html in "/search/templates/destroyerx." Below is the HTML I used for that HTML document:

<html>
<head>
<title><phpdig:title_message/></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<phpdig:my_page_header/>
<phpdig:my_page_sidebar/>
<phpdig:my_page_main/>
<phpdig:my_page_footer/>
</body>
</html>

Once I completed that, I tried going to http://www.destroyerx.net/search/search.php, but it gave me the following error message:

Fatal error: Call to undefined function: includes() in /home/destroyerx/public_html/search/libs/search_function.php on line 594

Anyway, I was hoping if someone on the forum can offer a solution to my problem. I managed to install the search engine to my Web site just fine. The only snag I'm facing right now is customizing the template. Anyway, thank you very much everyone for your time.

Ciao for now!

Charter
06-21-2004, 05:44 AM
Hi. If you are only including PHP files, you can remove the get_my_includes function, as this function reads but does not parse PHP files. The function is meant for text files like HTML files.

Next, change the following:


$my_page_header = includes("/home/destroyerx/search/templates/destroyerx/header.php");
$my_page_sidebar = includes("/home/destroyerx/search/templates/destroyerx/sidebar.php");
$my_page_main = includes("/home/destroyerx/search/templates/destroyerx/main.php");
$my_page_footer = includes("/home/destroyerx/search/templates/destroyerx/footer.php");


to the following:


$my_page_header = include("/home/destroyerx/search/templates/destroyerx/header.php");
$my_page_sidebar = include("/home/destroyerx/search/templates/destroyerx/sidebar.php");
$my_page_main = include("/home/destroyerx/search/templates/destroyerx/main.php");
$my_page_footer = include("/home/destroyerx/search/templates/destroyerx/footer.php");


Last, change the following:


$t_mstrings = compact('my_page_header','my_page_footer','powered_by_link','title_message' ,'phpdig_version','result_message','nav_bar','ignore_message','ignore_comme ss','pages_bar','previous_link','next_link','templates_links');


to the following:


$t_mstrings = compact('my_page_header','my_page_sidebar','my_page_main','my_page_footer', 'powered_by_link','title_message','phpdig_version','result_message','nav_ba r','ignore_message','ignore_commess','pages_bar','previous_link','next_link ','templates_links');


Keep everything else the same, and remember to remove any 'word' wrapping in the above code.

Destroyer X
06-21-2004, 10:47 AM
Well, I managed to do everything I was suggested to. However, now I have a new problem. Instead of the search page using the template files, it reverted back to the default search page. I think it might have something to do with the syntax of destroyerx.html in the "search/templates/destroyerx", but I'm not sure. Can someone offer any suggestions? Thanks for your time.

Ciao for now!

Charter
06-21-2004, 11:32 AM
Hi. In the config.php file, do you have the following set?

//template file and style
$template = "$relative_script_path/templates/destroyerx/destroyerx.html";

Destroyer X
06-21-2004, 01:20 PM
It's pretty embarassing that I'm having so much trouble configuring a template for PhpDig, but since this site is the origin of PhpDig, I feel as if my questions would be best answered here. I apologize if I inconveniene anyone.

Anyway, I did do the last thing that Charter said, but unfortunately when I went to http://www.destroyerx.net/search/search.php, it gave me a completely white screen. I wish I knew how the completely white screen was caused, but I don't. Does anyone have any theories why it's not displaying my template? Thanks for your time.

Ciao for now!

Charter
06-21-2004, 08:30 PM
Hi. Check the path of the include statements and see if it is correct, i.e. is it:

/home/destroyerx/public_html/search/templates/destroyerx/filename.php

or is it:

/home/destroyerx/search/templates/destroyerx/filename.php

Destroyer X
06-21-2004, 08:57 PM
Well, I can honestly say I feel myself getting closer to having this search engine configured for my Web site. Thank you everyone for putting up with me so far. Well, now http://www.destroyerx.net/search/search.php is showing bits of my template, but it's still not working yet. Here's what I have for error messages on http://www.destroyerx.net/search/search.php:

Warning: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32

Warning: MySQL Connection Failed: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32
Connection Error
--------------------------------------------------------------------------------

MySQL Error : Connection Error
Error Number: 0
Date : Mon, June 21, 2004 22:34:36
IP : 68.13.236.125
Browser : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Referer :
PHP Version : 4.2.2
OS : Linux
Server : Apache/2.0.40 (Red Hat Linux)
Server Name : www.destroyerx.net
Script Name : /search/search.php

Honestly, I have no idea why it's displaying that error message since the most exposure I've had to PHP was my FormMail script and phpBB (which I still need to configure a layout for *sigh*). Now, does anyone know why it would be giving me those error messages?

In the meantime, I guess I should be asking myself a brand new question. Well, before I installed PhpDig on my Web site, I had a Perl search engine called Perlfect Search, and in addition, I have a Perl image gallery called emAlbum. Now, while I'll be getting rid of these two Perl scripts to make way for PHP scripts such as PhpDig, Perlfect only had two HTML files to customize: search.html and no_match.html. Also, emAlbum only had one HTML file to customize which I named destroyerx.html. Is there any way that I could just use one PHP file for a template instead of creating several PHP files like header.php, sidebar.php, main.php, and footer.php? Since I use Macromedia Dreamweaver to apply a change in a .dwt template to all .html and .php files that've been created with a partictular .dwt file, it would be extremely convenient for me if only one .php file could be used as a template.

Once again, I would like to thank everyone for their time and patience in working with me on this. While I could do stuff to make a decent Web site layout with just HTML knowledge and Notepad, when it comes to PHP, I'm a lost puppy. In addition, I would like to thank the people who've developed this search engine script. When I'm finally able to configure it for my Web site, you guys will definately be a lifesaver. Thank you everyone for your time.

Ciao for now!

Destroyer X
06-22-2004, 10:33 PM
Well everyone, first, I like to thank Charter for helping me out every step of the way. Because of his help, I nearly have http://www.destroyerx.net/search/search.php completely configured. While I wasn't intending on doing this, I'm going to add a link to the Search page on my sidebar of my layout.

Anyway, I restored config.php and search_function.php to their default settings (thank goodness, I backed those up). After that, I replaced:

if ($template == 'array' || is_file($template)) {
$phpdig_version = PHPDIG_VERSION;
$t_mstrings = compact('powered_by_link','title_message','phpdig_version','result_message'
,'nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','n
ext_link','templates_links');
$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'templ
ate',$template);
if ($template == 'array') {
return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
}
else {
$t_strings = array_merge($t_mstrings,$t_fstrings);
phpdigParseTemplate($template,$t_strings,$table_results);
}
}

with

// check that the paths are correct or use full paths
$my_page_header = get_my_includes("../../dir/header.html");
$my_page_footer = get_my_includes("../../dir/footer.html");

if ($template == 'array' || is_file($template)) {
$phpdig_version = PHPDIG_VERSION;
$t_mstrings = compact('my_page_header','my_page_footer','powered_by_link','title_message'
,'phpdig_version','result_message','nav_bar','ignore_message','ignore_comme
ss','pages_bar','previous_link','next_link','templates_links');
$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'templ
ate',$template);
if ($template == 'array') {
return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
}
else {
$t_strings = array_merge($t_mstrings,$t_fstrings);
phpdigParseTemplate($template,$t_strings,$table_results);
}
}

After fixing the "word wrapping", I removed

$my_page_header = get_my_includes("../../dir/header.html");

and

$my_page_footer = get_my_includes("../../dir/footer.html");

as well as removed them from

$t_mstrings = compact('my_page_header','my_page_footer',

etc.

Once that was done, I created destroyerx.php and placed it in the template folder. After that, I changed the template file and style to

//template file and style
$template = "/home/destroyerx/public_html/search/templates/destroyerx.php";

Well, I'm nearly done with completely configuring the template to suit my needs. There're a few questions remaining which should completely wrap up using PhpDig on my Web site. Here they are:

1.) On the top of http://www.destroyerx.net/search/search.php I have a search bar and a Go graphic button that I want to use for the search engine like how I used it for Perlfect Search. Is there anyway I can configure that search field to work with PhpDig instead and still keep the search bar and the Go graphic intact?

2.) I am also running a Website Poll on my Web site called Advanced Poll v2.03. When I go to http://www.destroyerx.net/search/search.php and scroll down to where the poll's at, I get the following:

set_template_set("Destroyer X Template"); // Destroyer X Template = template name echo $php_poll->poll_process("newest"); ?>

While it does that on the search page, on the other pages like http://www.destroyerx.net/staff.php the Website Poll will display fine. I'm suspecting I need to do an include, but I'm not completely sure. Can someone offer me assistance as to whether or not this is right, and if so, how would I word the include on search_function.php and the template destroyerx.php?

3.) On the bottom of http://www.destroyerx.net/search/search.php there's text saying "Powered by PhpDig." I was wanting to not only make the text for this slightly larger (after all, this is a good search engine, and I really want to promote it), but I was also wanting to include the version number of PhpDig I have on my Web site. Where can I go to do this?

Anyway, I would like to thank everyone for putting up with me and my questions. This is a great script, and the tech support here is very friendly and prompt to respond. Thank you so much everyone for your time and cooperation.

Ciao for now!

Charter
06-23-2004, 09:39 AM
Hi. For one, try the following. Replace:

<form method="get" action="http://www.destroyerx.net/cgi-bin/perlfect/search/search.pl">
<td valign="top" width="177">
<div align="left" class="searchbar">

<!-- Begin Search Field -->

<input type="hidden" name="p" value="1">
<input type="hidden" name="lang" value="en">
<table width="140" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
&nbsp;<input type="text" name="q" size="15" maxlength="255" value="Search" style="font-family: Arial, Helevetica, sans-serif; font-size: 12px; color: #FFFFFF; background-color: #000000; border: 1px" onfocus="javascript:if(this.value=='Search') {this.value='';}">
</td>
<td valign="top">
&nbsp;<input type="image" src="../../images/nav_go.gif" alt="">
</td>
</tr>
</table>

<!-- End Search Field -->

</div>
</td>
</form>

with the following:

<form action='http://www.destroyerx.net/search/search.php' method='get'>
<td valign="top" width="177">
<div align="left" class="searchbar">

<!-- Begin Search Field -->

<input type='hidden' name='site' value='0'/>
<input type='hidden' name='path' value=''/>
<input type='hidden' name='result_page' value='search.php'/>
<table width="140" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
&nbsp;<input type="text" name="query_string" size="15" maxlength="255" value="Search" style="font-family: Arial, Helevetica, sans-serif; font-size: 12px; color: #FFFFFF; background-color: #000000; border: 1px" onfocus="javascript:if(this.value=='Search') {this.value='';}">
</td>
<td valign="top">
&nbsp;<input type="image" name="search" src="../../images/nav_go.gif" alt="">
</td>
</tr>
</table>

<!-- End Search Field -->

</div>
</td>
</form>

For two, the following:

<?php
include_once "/home/destroyerx/public_html/poll/booth.php";
$php_poll->set_template_set("Destroyer X Template"); // Destroyer X Template = template name
echo $php_poll->poll_process("newest");
?>

appears in the HTML source at http://www.destroyerx.net/search/search.php because it is not being parsed. There was also a "Warning: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32" error meaning that the poll script wasn't able to access the database. To include PHP code in the search page, you'd need to do the stuff mentioned ealier in this thread.

For three, find and edit the $powered_by_link variable in the search_function.php file. Look for PHPDIG_VERSION in the config.php file to get the version number.

Destroyer X
06-23-2004, 10:50 PM
Well, the search engine did work fine until I tried to mess with the PHP poll include. I'm still not understanding what I'm doing wrong, but here goes nothing. Here is what all i did.

First, I opened up Notepad, copied the following out of destroyerx.php in http://www.destroyerx.net/search/templates/

<?php
include_once "/home/destroyerx/public_html/poll/booth.php";
$php_poll->set_template_set("Destroyer X Template"); // Destroyer X Template = template name
echo $php_poll->poll_process("newest");
?>

and I saved this as a separate file in http://www.destroyerx.net/search/includes/ as poll.inc.php.

Next, what I did was opened up search_function.php and included the following:

// check that the paths are correct or use full paths
$my_poll_file = include("./includes/poll.inc.php");

if ($template == 'array' || is_file($template)) {
&nbsp;&nbsp;&nbsp;&nbsp;$phpdig_version = PHPDIG_VERSION;
&nbsp;&nbsp;&nbsp;&nbsp;$t_mstrings = compact('my_poll_file','powered_by_link','title_message','phpdig_version',' result_message','nav_bar','ignore_message','ignore_commess','pages_bar','pr evious_link','next_link','templates_links');
&nbsp;&nbsp;&nbsp;&nbsp;$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'templ ate',$template);
if ($template == 'array') {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$t_strings = array_merge($t_mstrings,$t_fstrings);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;phpdigParseTemplate($template,$t_strings,$table_results);
&nbsp;&nbsp;&nbsp;&nbsp;}
}

After that, I went into destroyerx.php in http://www.destroyerx.net/search/templates/ and replaced

<div align="center" class="sidebar" id="sidebarheaderfont"><b>Website Poll</b></div>
<?php
include_once "/home/destroyerx/public_html/poll/booth.php";
$php_poll->set_template_set("Destroyer X Template"); // Destroyer X Template = template name
echo $php_poll->poll_process("newest");
?>
<br>
</div>

with

<div align="center" class="sidebar" id="sidebarheaderfont"><b>Website Poll</b></div>
<phpdig:my_poll_file/>
<br>
</div>

While I thought I had everything working absolutely right this time, it gave the following message again, except this time it didn't show any of my template:

Warning: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32

Warning: MySQL Connection Failed: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32
Connection Error
--------------------------------------------------------------------------------

MySQL Error : Connection Error
Error Number: 0
Date : Thu, June 24, 2004 00:19:56
IP : 68.13.236.125
Browser : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Referer :
PHP Version : 4.2.2
OS : Linux
Server : Apache/2.0.40 (Red Hat Linux)
Server Name : www.destroyerx.net
Script Name : /search/search.php

Now, believe me, I've been reading up on the past threads, and I've been reading on this thread and trying to follow the advice of Charter, and while I've been able to get the search page working without the Website Poll, when I try to use the include, I keep messing up somewhere. Honestly, I don't know why it's giving me that error message, because I thought I configured search_functions.php, destroyerx.php, and config.php (when I set destroyerx.php as my template file) accordingly, but I messed up again, and it's starting to get frustrating. What I'm wanting to know is there anything else that needs to be done for the include to work?

Also, while I tried looking in my PHP and MySQL for Dummies book (bought that when I started getting into PHP for my phpBB), I couldn't find an answer to another one of my questions that's been deep inside my head, so I might as well ask it here:

What does parsing mean?

Well, once again, thanks to everyone for their time. I swear after this thing is configured, I won't be this lost again. Thanks everyone!

By the way, if the PHP code for /home/destroyerx/public_html/poll/include/class_mysql.php is needed, I posted a text file for it at http://www.destroyerx.net/class_mysql.txt

I've also posted config.php, search_function.php, and destroyerx.php as the following:

http://www.destroyerx.net/config.txt (with the values of username and password replaced with something else)
http://www.destroyerx.net/search_function.txt
http://www.destroyerx.net/destroyerx.txt

As one can see, I'm deserate to be able to run this include with PhpDig.

Once again, thanks everyone for your time and cooperation.

Ciao for now!

Charter
07-11-2004, 08:54 PM
Oops, thread got buried. Still having problems? If so, what's the code from the class_mysql.php file?

Destroyer X
07-12-2004, 07:54 AM
Hey, it's ok Charter. I knew that you were busy for a time, and since I don't know of anyone else who's proficient with PhpDig besides you and vinyl-junkie, I tried seeking advice from vinyl-junkie in the meantime. Unfortunately, my problem still remains even when following yours and vinyl-junkie's advice for parsing.

Anyway, out of frustration, I've deleted PhpDig and Advanced Poll, tables and all, and re-uploaded them from scratch. After configuring Advanced Poll, I tried to go for PhpDig. What I did since the re-upload is that I changed the template path from the default one to the following:


//template file and style
$template = "$relative_script_path/templates/destroyerx.php";


After that, I went into search_function.php and tried the advice that I got from vinyl-junkie. Below this code right here:


//===============================================
// do the search and display the results
// can be called in any page
function phpdigSearch($id_connect, $query_string, $option='start', $refine=0,
$refine_url='', $lim_start=0, $limite=10, $browse=0,
$site=0, $path='', $relative_script_path = '.', $template='')
{


I added the following PHP code:


include_once "/home/destroyerx/public_html/poll/booth.php";
ob_start();
require("/home/destroyerx/public_html/poll/booth.php");
$my_poll = ob_get_contents();
ob_end_clean();


After that, I added my_poll to the following:


if ($template == 'array' || is_file($template)) {
$phpdig_version = PHPDIG_VERSION;
$t_mstrings = compact('my_poll','powered_by_link','title_message','phpdig_version','resul t_message','nav_bar','ignore_message','ignore_commess','pages_bar','previou s_link','next_link','templates_links');
$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'templ ate',$template);
if ($template == 'array') {
return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
}
else {
$t_strings = array_merge($t_mstrings,$t_fstrings);
phpdigParseTemplate($template,$t_strings,$table_results);
}
}


Once that was done, I went to my template file, destroyerx.php, and added <phpdig:my_poll/> as shown below:

<div align="center" class="sidebar" id="sidebarheaderfont"><b>Website Poll</b></div>
<br>
<phpdig:my_poll/>
<br>
</div>

When all was said and done and I finally went to http://www.destroyerx.net/search/search.php to try it out, thinking it would finally work, I received the same error message yet again:

Warning: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32

Warning: MySQL Connection Failed: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32
Connection Error

MySQL Error : Connection Error
Error Number: 0
Date : Mon, July 12, 2004 09:40:05
IP : 68.13.236.125
Browser : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Referer :
PHP Version : 4.2.2
OS : Linux
Server : Apache/2.0.40 (Red Hat Linux)
Server Name : www.destroyerx.net
Script Name : /search/search.php

While there's probably someone out there saying give up and just drop the Website Poll, I prefer to have it to get the input of people that visit my Web site when it comes to games, cartoons, or whatever I poll about. Anyway, I posted the following links that may be of interest:

For Advanced Poll:

http://www.destroyerx.net/poll/index.php
http://www.destroyerx.net/poll/include/class_mysql.txt

For PhpDig:

http://www.destroyerx.net/search/search.txt
http://www.destroyerx.net/search/includes/config.txt
http://www.destroyerx.net/search/libs/search_function.txt
http://www.destroyerx.net/search/templates/destroyerx.txt

I also noticed in my Advanced Poll folder in http://www.destroyerx.net/poll/include/.htaccess the .htaccess file said the following:

deny from all

I'm not sure if that's of any relevance or not, but I thought I'd post that anyway. Well, I'd like to thank Charter and vinyl-junkie for sticking with me on this thing. If anymore information is needed to help solve this problem, I'm willing to post anything from my Advanced Poll and PhpDig coding, with the exception of usernames and passwords. Thank you all very much for your time.

Ciao for now!


Edit:

Well, I just now tested out the link to class_mysql.txt at http://www.destroyerx.net/poll/include/class_mysql.txt to make sure everyone can view it, and it pulled up my Error 403: Access Forbidden! page. Anyway, I added the .txt file in a new spot:

http://www.destroyerx.net/class_mysql.txt

Thanks everyone for your time and cooperation!

Ciao for now!

Charter
07-12-2004, 08:51 PM
Hi. Your poll script isn't connecting to the database:

Warning: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32

Warning: MySQL Connection Failed: Access denied for user: 'apache@localhost' (Using password: NO) in /home/destroyerx/public_html/poll/include/class_mysql.php on line 32
Connection Error

Perhaps check that your poll script and PhpDig aren't overwriting the same name variables of each other.

Destroyer X
07-13-2004, 07:38 AM
Well, I managed to give up on the database version of Advanced Poll and deleted it. Instead of using the database version, I'm using the textfile version of Advanced Poll, and remarkably, I had very little to reconfigure. Honestly, I'm not sure what the benefit is of using a database poll over a textfile poll, but hopefully it'll be much easier to mess with for PhpDig.

Anyway, after installing the textfile version of the script, I went ahead and deleted the .htaccess file in http://www.destroyerx.net/poll/include/.htaccess since it said the following:

deny from all

When all was said and done, I went to http://www.destroyerx.net/search/search.php thinking it would finally work since my poll isn't running on a database anymore. Lo and behold, I managed to receive another error message:

Fatal error: Cannot redeclare class poll in /home/destroyerx/public_html/poll/include/class_poll.php on line 10

I've managed to provide a text version of class_poll.php at http://www.destroyerx.net/poll/include/class_poll.txt

Unfortunately, I don't understand how to correct this fatal error so I can use Advanced Poll on the generated PhpDig search pages. Can anyone offer any suggestions?

Thanks for your time and cooperation.

Ciao for now!

Destroyer X
07-14-2004, 12:21 PM
Under the suggestion of vinyl-junkie, I posted booth.php of my Advanced Poll code on my server as a .txt file. It can be viewed here for analysis:

http://www.destroyerx.net/poll/booth.txt

Thank you for your time and cooperation.

Ciao for now!

Destroyer X
07-14-2004, 11:27 PM
Well, once again, I tried to fiddle around with trying to get the include to work. Here are all the current .txt files for the PHP files:

--------------------------
Advanced Poll v2.0.3
--------------------------

http://www.destroyerx.net/poll/demo_1.php (thought this might be useful too)

http://www.destroyerx.net/poll/booth.txt

http://www.destroyerx.net/poll/faq.txt (there was no PHP version of this file; it was included in the zip file)

http://www.destroyerx.net/poll/include/class_poll.txt


-----------------
PhpDig v1.8.3
-----------------

http://www.destroyerx.net/search/search.txt

http://www.destroyerx.net/search/includes/config.txt

http://www.destroyerx.net/search/includes/poll.inc.txt (I decided to do this again for now)

http://www.destroyerx.net/search/libs/search_function.txt

http://www.destroyerx.net/search/templates/destroyerx.txt


Once again, after all was said and done again, I got the following error message:

Fatal error: Cannot redeclare class poll in /home/destroyerx/public_html/poll/include/class_poll.php on line 10

Now, I'm not sure what it means by cannot redeclare class poll, but as far as I know, I've done everything I could to analyze how to fix this problem I've been having. Heck, if there was a program that could just say, "hey, you need to do such and such here to fix your problem", then I would've got it already. Hopefully, all the links that've been provided will be of help, because I don't know what else I should post at this point.

Thanks for your time and cooperation.

Ciao for now!

Charter
07-15-2004, 12:41 PM
Hi. In search_function.php you have the following:

include_once "/home/destroyerx/public_html/poll/booth.php";
ob_start();
require("/home/destroyerx/public_html/poll/booth.php");
$my_poll = ob_get_contents();
ob_end_clean();

This causes the "Cannot redeclare class poll" error because the include_once includes the code and then afterwards there is a require which includes the code again. Remove the include_once line and see what happens.

Destroyer X
07-15-2004, 08:54 PM
Well actually, I forgot to upload my updated search_function.txt file into my server. Well, I managed to do that a little while ago. Anyway, I removed the following:


include_once "/home/destroyerx/public_html/poll/booth.php";
ob_start();
require("/home/destroyerx/public_html/poll/booth.php");
$my_poll = ob_get_contents();
ob_end_clean();


and added the following below $powered_by_link .= "<a href=\"http://www.phpdig.net/\">Powered by PhpDig v.1.8.3</a><br></font>";


$my_poll_file = include("/home/destroyerx/public_html/search/includes/poll.inc.php");


Within my poll.inc.php, I have the following:


<?php

/*path*/
$poll_path = "/home/destroyerx/public_html/poll";

require $poll_path."/include/config.inc.php";
require $poll_path."/include/class_poll.php";

$php_poll = new poll();

/*newest poll*/
include_once "/home/destroyerx/public_html/poll/booth.php";
echo $php_poll->poll_process("newest");

?>


However, it's still causing the error below:

Fatal error: Cannot redeclare class poll in /home/destroyerx/public_html/poll/include/class_poll.php on line 10

I was wondering if I would need to remodify poll.inc.php, but at the same time, I don't know how I would need to do that. Does anyone have any suggestions?

Ciao for now!

vinyl-junkie
07-15-2004, 09:04 PM
I believe you need to leave that chunk of code in your script that you removed.

Your problem is that you are including class_poll.php more than once in your code somewhere. Find where that is and remove one of them. If that doesn't work, put in back in and remove the other one. If that still doesn't work, or you're getting a different error message, let us know.

FWIW, I do have on my "to-do" list for the weekend of looking at your .txt versions of your scripts. I just spent this evening testing phpdig 1.8.3 with all my customized code. It's looking good! :D

Charter
07-15-2004, 09:33 PM
Hi. Your poll.inc.php includes class_poll.php and booth.php, and then booth.php includes class_poll.php again, hence the error.

In search_function.php do:

ob_start();
require("/home/destroyerx/public_html/search/includes/poll.inc.php");
$my_poll_file = ob_get_contents();
ob_end_clean();

and also in search_function.php do:

$t_mstrings = compact('my_poll_file','js_for_clicks','rss_feed_link','powered_by_link','t itle_message','phpdig_version','result_message','nav_bar','ignore_message', 'ignore_commess','pages_bar','previous_link','next_link','templates_links') ;

But replace your poll.inc.php with:

<?php

$include_path = "/home/destroyerx/public_html/poll";

if (!isset($PHP_SELF)) {
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
$PHP_SELF = $HTTP_SERVER_VARS["PHP_SELF"];
if (isset($HTTP_GET_VARS)) {
while (list($name, $value)=each($HTTP_GET_VARS)) {
$$name=$value;
}
}
if (isset($HTTP_POST_VARS)) {
while (list($name, $value)=each($HTTP_POST_VARS)) {
$$name=$value;
}
}
if(isset($HTTP_COOKIE_VARS)){
while (list($name, $value)=each($HTTP_COOKIE_VARS)){
$$name=$value;
}
}
}

require $include_path."/include/config.inc.php";
require $include_path."/include/class_poll.php";

$php_poll = new poll();
echo $php_poll->set_include_path($include_path);

?>

Destroyer X
07-15-2004, 11:17 PM
Well, after who knows how long with messing with this, all I can say is......hallelujah!

PhpDig is parsing the poll.inc.php include almost exactly the way I wanted it to. Before I forget, here is what I did.

As suggested, I made the changes in search_function.php. Then in poll.inc.php, I did a few modifications to the coding. Instead of the code looking like this:


<?php

$include_path = "/home/destroyerx/public_html/poll";

if (!isset($PHP_SELF)) {
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
$PHP_SELF = $HTTP_SERVER_VARS["PHP_SELF"];
if (isset($HTTP_GET_VARS)) {
while (list($name, $value)=each($HTTP_GET_VARS)) {
$$name=$value;
}
}
if (isset($HTTP_POST_VARS)) {
while (list($name, $value)=each($HTTP_POST_VARS)) {
$$name=$value;
}
}
if(isset($HTTP_COOKIE_VARS)){
while (list($name, $value)=each($HTTP_COOKIE_VARS)){
$$name=$value;
}
}
}

require $include_path."/include/config.inc.php";
require $include_path."/include/class_poll.php";

$php_poll = new poll();
echo $php_poll->set_include_path($include_path);

?>


I modified it slightly to make it look like this so it'll grab my poll template and display the latest poll:


<?php

/*path*/
$include_path = "/home/destroyerx/public_html/poll";

if (!isset($PHP_SELF)) {
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
$PHP_SELF = $HTTP_SERVER_VARS["PHP_SELF"];
if (isset($HTTP_GET_VARS)) {
while (list($name, $value)=each($HTTP_GET_VARS)) {
$$name=$value;
}
}
if (isset($HTTP_POST_VARS)) {
while (list($name, $value)=each($HTTP_POST_VARS)) {
$$name=$value;
}
}
if(isset($HTTP_COOKIE_VARS)){
while (list($name, $value)=each($HTTP_COOKIE_VARS)){
$$name=$value;
}
}
}

require $include_path."/include/config.inc.php";
require $include_path."/include/class_poll.php";

$php_poll = new poll();

/*template*/
$php_poll->set_template_set("Destroyer X Template"); // Destroyer X Template = template name

/*newest poll*/
echo $php_poll->poll_process("newest");

?>


Now, my poll is displaying at http://www.destroyerx.net/search/search.php

However, I ran into a very small problem (which I hope is very very simple to fix). While it's not in the realm of PhpDig, it's something I hope it'll be easily fixed. At http://www.destroyerx.net/sample.php, it displays the Website Poll near the bottom as the following:

----------------
Website Poll
----------------

Which OS is your Web site running on?

BSD
Linux
Solaris
FreeBSD
MacOSX
Windows NT
others

Vote Button

View Results

Advanced Poll v2.02

However, at http://www.destroyerx.net/search/search.php, it shows almost all of the poll content above, except it reduces the Vote Button to a very small textless button, the View Results link is completely gone, and where it says Advanced Poll v2.02, it now says Advanced Poll v.

I know it seems kind of stupid of me to worry about such a thing, but I don't understand why it would do that though. Does anyone have any suggestions or comments :confused: I'm thinking it may have something to do with how I ordered the contents of php.inc.php, because on sample.php where the poll code is displayed on that page, here's all that's there:


<?php
include_once "/home/destroyerx/public_html/poll/booth.php";
$php_poll->set_template_set("Destroyer X Template"); // Destroyer X Template = template name
echo $php_poll->poll_process("newest");
?>


Now if I can get the poll on http://www.destroyerx.net/search/search.php, to display like it is at http://www.destroyerx.net/sample.php, http://www.destroyerx.net/feedback.php, or whereever, that would really make me jump for joy.

Once again Charter and vinyl-junkie, thank you two so much for all of your help :) This is you two's victory!

Ciao for now!

Charter
07-15-2004, 11:29 PM
Hi. Go look in the poll template files and/or poll config file for the HTML that generates the following and edit it?

Button with no text: <input type="submit" value="" class="input">
Button with text: <input type="submit" value="CLICK TO VOTE" class="input">

No version number: <a href="http://www.proxy2.de" target="_blank" title="Advanced Poll">Advanced Poll v</a>
With version number: <a href="http://www.proxy2.de" target="_blank" title="Advanced Poll">Advanced Poll vERSION X.X.X</a>

Destroyer X
07-29-2004, 10:32 PM
Well everyone, I have given up on trying to parse Advanced Poll with PhpDig. Although, the text version of the script was parsed successfully, there were still errors with Advanced Poll from the parsing that I couldn't even correct from the administration panel of Advanced Poll. While I'm disappointed by this, it does leave me with a few options. I could either:

1.) Take a few months to learn PHP (not sure what reference book would be the best for a PHP beginner such as myself) and create my own Web site poll from scratch

2.) Pay for a commercial PHP Web site poll such as Vote! Pro 4.0 or chumpsoft :: phpQuestionnaire and hoped it can be easily parsed with no errors at all with the commercial Web site polls

3.) Pay someone to create a PHP Web site poll that can easily be parsed with PhpDig

4.) Keep searching for a free PHP Web site poll that has decent enough features and can be easily parsed with PhpDig

However, if anyone knows of a decent free Web site poll script that is still in development (I would think that Fusion Poll would be nice if the developer for it didn't drop off the face of the Internet, taking his beta of the next version of it with him because I've already tried to mess with that poll script with no luck), please feel free to send me a Private Message.

I would like to give my thanks to Charter and vinyl-junkie for taking the time to help me with the parsing of Advanced Poll with PhpDig.

To everyone else who kept reading this thread, thank you very much for your time.

Ciao for now!

vinyl-junkie
07-29-2004, 10:53 PM
Hi DestroyerX,

I'm disappointed that you weren't able to get your poll working exactly as you wanted it, but you're still a lot further down the road than you were when you started.

I don't know how keen you are on the idea of learning PHP, but I can recommend some books that make it pretty easy to learn. The first is called Build Your Own Database Driven Website Using PHP & MySQL (http://www.sitepoint.com/books/phpmysql1/) and is a great beginner book. If you master that and want to learn more, there is The PHP Anthology (http://www.sitepoint.com/books/phpant1/), which is a 2-volume set. These books will teach you just about anything you want to know about PHP.

Alternatively, if you would just like the easy way out and pay someone else to do the work for you, I've heard that Rent A Coder (http://www.rentacoder.com/RentACoder/default.asp) is pretty good.

Hope this helps. :)