".$inf["pollerTitle"].""; // Output poller title $resOptions = mysql_query("select * from poller_option where pollerID='$pollerId' order by pollerOrder") or die(mysql_error()); // Find poll options, i.e. radio buttons while($infOptions = mysql_fetch_array($resOptions)){ if($infOptions["defaultChecked"])$checked=" checked"; else $checked = ""; echo "
First thing that's noticable: You haven't used the full PHP open command. U have a "short open" command which probably won't work unless PHP is configured to accept it (which it isnt by default, and by the looks as it outputs it as text when you right click and "view source")
For example, you can see this which should have been executed, not displayed.
Code:
<?
require_once("dbConnect.php");
?>
They wanna read <?PHP instead of <?. The close tags ?> are ok.
If that in itself doesn't fix it, post again and we can check it out. The original code would be good, as when I hit View Source I can't see all of the code involved.
__________________
outseeker - http://outer.reaches.dyndns.org/index.php
I hope this helped someone. Due to this forums lame rep system penalising me for nothing, and admins inability to do anything about it, I'm sorry to say I will no longer be online here. Pride is important. Good Luck All.
<?PHP
require_once("dbconnect.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<?
@include($_SERVER['DOCUMENT_ROOT']."/config/metatags.inc");
?>
<title>Ajax poller</title>
<style type="text/css">
/* DEMO CSS */
img{
border:0px;
}
#mainContainer{
width:760px;
margin:0 auto;
text-align:left;
background-color:#FFF;
}
#mainContent{
padding:10px;
}
.clear{
clear:both;
}
</style>
<link rel="stylesheet" href="css/ajax-poller.css" type="text/css">
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/ajax-poller.js"> </script>
</HEAD>
<BODY>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" onsubmit="return false" method="post">
<div id="mainContainer">
<div id="header"><img src="/images/heading3.gif"></div>
<div id="mainContent">
<?
$pollerId = 3; // Id of poller
?>
<!-- START OF POLLER -->
<div class="poller">
<div class="poller_question" id="poller_question<? echo $pollerId; ?>">
<?
// Retreving poll from database
$res = mysql_query("select * from poller where ID='$pollerId'");
if($inf = mysql_fetch_array($res)){
echo "<p class=\"pollerTitle\">".$inf["pollerTitle"]."</p>"; // Output poller title
$resOptions = mysql_query("select * from poller_option where pollerID='$pollerId' order by pollerOrder") or die(mysql_error()); // Find poll options, i.e. radio buttons
while($infOptions = mysql_fetch_array($resOptions)){
if($infOptions["defaultChecked"])$checked=" checked"; else $checked = "";
echo "<p class=\"pollerOption\"><input$checked type=\"radio\" value=\"".$infOptions["ID"]."\" name=\"vote[".$inf["ID"]."]\" id=\"pollerOption".$infOptions["ID"]."\"><label for=\"pollerOption".$infOptions["ID"]."\" id=\"optionLabel".$infOptions["ID"]."\">".$infOptions["optionText"]."</label></p>";
}
}
?>
<a href="#" onclick="castMyVote(<? echo $pollerId; ?>,document.forms[0])"><img src="images/vote_button.gif"></a>
</div>
<div class="poller_waitMessage" id="poller_waitMessage<? echo $pollerId; ?>">
Getting poll results. Please wait...
</div>
<div class="poller_results" id="poller_results<? echo $pollerId; ?>">
<!-- This div will be filled from Ajax, so leave it empty --></div>
</div>
<!-- END OF POLLER -->
<script type="text/javascript">
if(useCookiesToRememberCastedVotes){
var cookieValue = Poller_Get_Cookie('dhtmlgoodies_poller_<? echo $pollerId; ?>');
if(cookieValue && cookieValue.length>0)displayResultsWithoutVoting(<? echo $pollerId; ?>); // This is the code you can use to prevent someone from casting a vote. You should check on cookie or ip address
}
</script>
<p>This is an example of a poll script. It uses Ajax(Asyncron Javascript And XML) to send your vote to the server. Ajax is also used to return the results from this poll to your browser.</p>
<p>In this demo, I haven't limited the number of votes per user. This is something you can implement by setting the Javascript variable
useCookiesToRememberCastedVotes to true in the script or by implementing your own method.</p>
</div>
<div class="clear"></div>
</div>
</form>
</BODY>
</HTML>
Got it sorted for ya mate. Good call about the extension Andrew. Unless you can edit the PHP.INI file for your server and add .html as a php executable extension you need to rename your ajax-poller.html to .php. Now it will just show the vote button and no poll. Because by default $pollerId=3. There is only one poll in the demo database so $pollerId=1;
That worked fine for me! (once I remembered to execute createDbTables.php after editing it for dbname pass etc.) it's running at http://outer.reaches.dyndns.org/poller/ajax-poller.php till you say u got yours working.
My previous suggestion of short open tags is irrelevant by the way. Their demo code worked ok without any changes there. Oh yeah, don't forget clickin here if ur a happy chappy! http://www.codingforums.com/reputation.php?p=656586
__________________
outseeker - http://outer.reaches.dyndns.org/index.php
I hope this helped someone. Due to this forums lame rep system penalising me for nothing, and admins inability to do anything about it, I'm sorry to say I will no longer be online here. Pride is important. Good Luck All.
Last edited by outseeker; 02-16-2008 at 03:58 AM..
Reason: added mention of my previous suggestion
They are all in the MySQL Database you have set up mate. I recommend www.sql-front.com for easily connecting and manipulating these. Same details u put in the config file for username and password. Too easy
__________________
outseeker - http://outer.reaches.dyndns.org/index.php
I hope this helped someone. Due to this forums lame rep system penalising me for nothing, and admins inability to do anything about it, I'm sorry to say I will no longer be online here. Pride is important. Good Luck All.
You mustn't have the correct details for username, password and database in your files. Edit them and ensure all details are correct. If they're correct, running the php file that installs tables will do it's job, and the admin will add polls.
__________________
outseeker - http://outer.reaches.dyndns.org/index.php
I hope this helped someone. Due to this forums lame rep system penalising me for nothing, and admins inability to do anything about it, I'm sorry to say I will no longer be online here. Pride is important. Good Luck All.
__________________
outseeker - http://outer.reaches.dyndns.org/index.php
I hope this helped someone. Due to this forums lame rep system penalising me for nothing, and admins inability to do anything about it, I'm sorry to say I will no longer be online here. Pride is important. Good Luck All.
Yeah have you edited createDbTables.php? It wants your login and database details manually entered itself just like the admin file and the index file. If you run createdbtables.php with correct username etc it will add the database entries for the poller. Just put it's address in the address bar, the same way you are viewing your website. Like yourwebsite.com/poller/createdbtables.php. Then view the poller. It worked fine for me. Have you got a link for us dude? You seem to be havin a lot of trouble, but I have no link for me to play with and discover the fault ehehe it worked just fine on my system! You're not double clicking the createdbtables in your windows explorer or something are u? hehe it does need to be on the live server
__________________
outseeker - http://outer.reaches.dyndns.org/index.php
I hope this helped someone. Due to this forums lame rep system penalising me for nothing, and admins inability to do anything about it, I'm sorry to say I will no longer be online here. Pride is important. Good Luck All.