...

View Full Version : PHP Polling Install Question



mbdonner
08-10-2007, 06:51 PM
Hello -

I am trying to install a php script for polling on my website and have run into a bit of a snag.

In the config.php file, I'm not sure how to configure the relative path for the templates folder.

Here is a portion from the config.php file:

// change to match your server's configuration
define(hostname,"localhost"); // mysql server host name
define(dbname,"dbnamehere"); // mysql database name
define(username,"mysqlusernamehere"); // mysql user name
define(password,"mysqlpasswordhere"); // mysql password

// directory where templates are located (must end foward slash)
define(templatedir,"/home/www/codemunkyx/www/www.free-php.net/htdocs/demo/SimplePoll/templates/");

// url to the script main directory (must end foward slash)
define(simplepollurl,"http://www.free-php.net/demo/SimplePoll/");
?>

I got all the database info configured fine, but it seems like I'm not configuring the bottom part correctly.

Here's is how I've got it configured (FYI - I put all the files into a folder called "poll" in the main directory):

// directory where templates are located (must end foward slash)
define(templatedir,"/home/poll/templates/");

// url to the script main directory (must end foward slash)
define(simplepollurl,"http://www.catholic-interactive.com/poll/");

Thanks so much in advance for your help - I appreciate it!

Inigoesdr
08-10-2007, 10:38 PM
My guess would be "templates/" if you're looking for the relative path.

mbdonner
08-11-2007, 08:38 PM
Thanks for the reply - but that didn't work either - the thing is...I know this is a simple PHP issue, but I haven't a clue about PHP....

Inigoesdr
08-12-2007, 01:33 AM
It's not really a "PHP issue", you just haven't set the path correctly.

Try: /home/content/m/b/d/mbdonner/html/catholic-interactive/poll/templates/
Incidentally you should password protect the admin directory asap.

mbdonner
08-12-2007, 02:24 AM
AWESOME - that was it. Thanks so much for your reply and your time.

THANKS!!!

By the way, how do I password protect the admin directory?

Seriously, thanks!!!

Inigoesdr
08-12-2007, 02:39 AM
http://www.google.com/search?hl=en&q=password+protect+directory+with+htaccess

mbdonner
08-12-2007, 03:24 AM
great - thanks - you're going to think I'm a total idiot, but I'm having trouble with a different polling script on a different site.....

I'm testing which poll script I like best, and tried to install another one. The admin page and testing works great, but when I try to include the php in a page and pull that page up, I get this:

Warning: main(/home/content/m/b/d/mbdonner/html/toplinepublishing/poll//poll.php): failed to open stream: No such file or directory in /home/content/m/b/d/mbdonner/html/poll1.php on line 9

Warning: main(/home/content/m/b/d/mbdonner/html/toplinepublishing/poll//poll.php): failed to open stream: No such file or directory in /home/content/m/b/d/mbdonner/html/poll1.php on line 9

Warning: main(): Failed opening '/home/content/m/b/d/mbdonner/html/toplinepublishing/poll//poll.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/b/d/mbdonner/html/poll1.php on line 9

Again, it's the path or something. I obviously can't figure it out from your help on the other script.

Any suggestions?

By the way, here is the config.php file:



<?php


/***************************** ADMIN AREA *************************************/
$id="admin";
$pw="admin";


/************************ Poll4All relative path ******************************/
// set poll4all folder path from page will display poll.
// this is the same path used in include statement for poll.php file.
// example: $scriptPath = "../script/poll4all/";
$scriptPath = "";



/**************************** POLL STYLE **************************************/

// General
$border = 1; // poll border
$width = 300; // poll table width
$cellpadding = 5; // poll table padding
$bgColor = '#FFFFFF'; // poll background color
$font = 'Verdana'; // poll font (question & answers)

// Question
$questionAlign = 'center'; // question text align
$questionColor = '#000000'; // question text color
$questionBgColor = '#ECECEC'; // question background color
$questionSize = '10'; // question font size (in pixel)

// Answers
$optionsAlign = 'left'; // answers text align
$optionColor = '#000000'; // answers, vote and percentage text color
$oddBgColor = '#FFFFFF'; // odd answer background color
$evenBgColor = '#FFFFFF'; // even answer background color
$answerSize = '12'; // answers,vote and percentage text size
$barBg = '#FFFFFF'; // progress bar background color
$percentageBg = '#FFFFFF'; // votes and percentage text background color

// Random Colors Mode ( 0:disable , 1:enable )
$RandomColors=1;

?>


Again, I uploaded all the files into a folder called "poll"

Thanks so much.....

Inigoesdr
08-12-2007, 03:27 AM
The path you're trying to include is wrong. Make sure the path points to a folder that exists, and remove the forward slash at the end.

mbdonner
08-12-2007, 03:38 AM
OK, so for example, the main site is http://www.toplinepublishing.com and the folder is "poll"...
what is the correct path?

(I don't get this path thing....obviously)

Thanks!!

Inigoesdr
08-12-2007, 03:45 AM
From the script:

/************************ Poll4All relative path ******************************/
// set poll4all folder path from page will display poll.
// this is the same path used in include statement for poll.php file.
// example: $scriptPath = "../script/poll4all/";
$scriptPath = "";

Also, I get a 404 at http://www.toplinepublishing.com/poll/
Did you upload the folder elsewhere, and try to include it from toplinepublishing?

mbdonner
08-12-2007, 03:48 AM
Do you have Yahoo Messenger IM by the way?

Or would you be so kind if I called?

Or I just shut up and keep using the forum?:)

Inigoesdr
08-12-2007, 03:50 AM
No, I don't. You should use the forum =]

mbdonner
08-12-2007, 03:53 AM
OK - cool....

OK - well, I uploaded the files into a folder in toplinepublishing.com called "poll" - there is no index file in "poll" so maybe that's why you get a 404

Check out http://www.toplinepublishing.com/poll/setup.php

Also, I know where to enter the path in the config.php file/script above, but WHAT to enter, I don't know.

In other words, what is the correct path to put in there?

Thanks!!!!!

Inigoesdr
08-12-2007, 04:01 AM
Well, assuming you're using it in the web root directory ie(http://website.com/) you should be able to use
$scriptPath = "/poll/"; or just "poll/".

mbdonner
08-12-2007, 04:14 AM
OK - I configured the configure.php with that path and then here is the instruction:

4. In the page you want the poll displayed use this code (must be php file):

<?php include("AJpoll_path/poll.php"); ?>

So I created a php file named "poll1.php" and uploaded it into the root directory (http://www.toplinepublishing.com/poll1.php). This file has the following:



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title></title>
</head>
<body>
<?php include("/poll/poll.php"); ?>
</body>
</html>


and this was the result (at http://www.toplinepublishing.com/poll1.php):

Warning: main(/poll/poll.php): failed to open stream: No such file or directory in /home/content/m/b/d/mbdonner/html/poll1.php on line 9

Warning: main(/poll/poll.php): failed to open stream: No such file or directory in /home/content/m/b/d/mbdonner/html/poll1.php on line 9

Warning: main(): Failed opening '/poll/poll.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/b/d/mbdonner/html/poll1.php on line 9

In case this helps, here is the total README.TXT file:




:: INDEX ::

- About
- Features
- Requirements
- Files Description
- Installation & Usage


.: about:
--------------------------------------------------------------------------------
Create and manage your own poll is REALLY easy with AJPoll.
This free php script lets you create, edit and test your poll (up to 7 answers) through an easy to use web interface.
You may insert your poll into any page you want simply including one php file.
AJPoll show results as colored graphical bars plus votes number and percentage.
It prevent multiple votes using cookies and store all information in a text file so you don't need any database.
AJPoll is valid XHTML 1.0 code and is viewable with any browser, fully customizable style.
Note: You can manage and run just one poll, every new poll will replace the older one.


.: Features:
--------------------------------------------------------------------------------
- Display your poll is very simple, just include one php file into your webpage
and your news will be published automatically.
- No database needed
- Fully customizable look to fit well into any page.
- Up to 7 answers
- Colored graphical bar (random (different) color function)
- Viewable with any browser (tested on Mozilla/Firefox, Ie, Opera).
- Valid XHTML 1.0 Transitional Code!


.: Requirements:
--------------------------------------------------------------------------------
Web server with PHP (this tool is tested with PHP 5, but should work with earlier and previous versions).



.: Files Description:
--------------------------------------------------------------------------------
- config.php : settings for AJPoll
- setup.php : the main script, it manage database-file and allow you to create and edit your poll
- poll.php : the file to include in your web page to show created poll
- txt/txtdb.ini.php : database-file used to store information about poll, don't edit manually!
- includes/configmagik.php : a file reader/writer class by Benny Zaminga
- includes/functions : some useful functions...


.: Installation & Usage:
--------------------------------------------------------------------------------
1. Download AJPOll and edit the config.php file to suite your needs.

2. Place the files anywhere in your web directory:
All files must be placed in the same directory observing directory structure.
Set the attributes of the file "txtdb.ini.php" to 666 (meaning read and write access for all parties).

3. Open up your webbrowser to:

http://www.yourserver.com/poll/setup.php

Default user id & password are: admin, admin.
You can change default values in the "config.php" file.

The script will check database-file (and if is writable) then will show the admin panel to create and edit your poll.

4. In the page you want the poll displayed use this code (must be php file):

<?php include("AJpoll_path/poll.php"); ?>





Thanks for your continued help!!

Inigoesdr
08-12-2007, 04:31 AM
Don't use the first forward slash for file paths. Starting with the slash tells the server to start from the root directory. If you use it when you link things in HTML it will start from the web root directory. So, use "poll/".

mbdonner
08-12-2007, 08:01 PM
Awesome - that worked. Wow you have really helped me out.

There is one little snag that I'm sure is just as easy to fix.

If you go take the poll at http://www.toplinepublishing.com/poll1.php - select an answer and hit submit - it will then take you to the results page, and that page has this up top:

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/b/d/mbdonner/html/poll1.php:9) in /home/content/m/b/d/mbdonner/html/poll/includes/functions.php on line 35

What is going on here?

Thanks a ton!!!!!!!!!!

Inigoesdr
08-12-2007, 08:43 PM
There's a more in-depth article here (http://www.codingforums.com/showpost.php?p=300877&postcount=6), but basically something is being output in poll1.php on line 9 that is causing the file headers to be sent to the user before a function that sends the headers is used(header(), etc.).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum