I downloaded a blog software and there was basic instructions....create db run .txt file to create and populate tables etc......
Anyway I am getting the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/major04/public_html/blog/weblog_poll.php on line 46
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/major04/public_html/blog/weblog_poll.php on line 60
Here is the piece of code it is having a problem with:
<?php
$poll_id = 1;
if (isset ($cookie)) {
if ($cookie == 'delete' OR $voted != $poll_id) {
setcookie("voted", "", time() - 6048000);
echo '<script>location.href="index.php"</script>';
}
}
elseif (isset ($voted)) {
if ($voted != $poll_id) {
echo '<script>location.href="weblog_poll.php?cookie=delete"</script>';
}
}
if (isset ($_POST["poll_submit"])) {
include "connect.php";
$query = "SELECT voted FROM poll_answers WHERE id='$answer_id' AND poll_id='$poll_id'";
$exec = mysql_query($query);
$result = mysql_fetch_array($exec);
$voted = $result["voted"] + 1;
$query = "UPDATE poll_answers SET voted='$voted' WHERE id='$answer_id' AND poll_id='$poll_id'";
$exec = mysql_query($query);
setcookie("voted", $poll_id, time() + 6048000);
echo "<script>location.href='$HTTP_REFERER'</script>";
}
else {
echo "<table cellspacing=0 cellpadding=0 width=100%>
<tr>
<td class='menu_right_header' style='padding-left: 1px;'>
<b>Poll</b>
</td>
</tr>
<tr>
<td class='menu_right'>
";
$query = "SELECT title FROM poll WHERE id='$poll_id'";
$exec = mysql_query($query);
$result = mysql_fetch_array($exec);
$title = $result["title"];
echo "<b>$title</b><br><br>
";
if (!isset ($voted)) {
echo "<form method=post action=weblog_poll.php>
<table cellspacing=0 cellpadding=0>
";
$query = "SELECT id,answer FROM poll_answers WHERE poll_id='$poll_id' ORDER BY id";
$exec = mysql_query($query);
while ($result = mysql_fetch_array($exec)) {
$id = $result["id"];
$answer = $result["answer"];
echo "<tr>
<td class='form'>
<input class='poll' name=answer_id type=radio value='$id'>
</td>
<td class='form' valign=top>
$answer
</td>
</tr>
";
}
echo "</table>
<input name=poll_id type=hidden value='$poll_id'>
<input name=poll_submit type=submit value='vote'>
</form>
";
}
else {
echo "<table cellspacing=0 cellpadding=0>
";
$query = "SELECT SUM(voted) AS total_votes FROM poll_answers WHERE poll_id='$poll_id'";
$exec = mysql_query($query);
$result = mysql_fetch_array($exec);
$total_votes = $result["total_votes"];
$query = "SELECT answer,voted FROM poll_answers WHERE poll_id='$poll_id' ORDER BY voted DESC, id";
$exec = mysql_query($query);
while ($result = mysql_fetch_array($exec)) {
$answer = $result["answer"];
$voted = $result["voted"];
$percentage = round ($voted / $total_votes * 100);
$width = round($percentage * 1.8);
echo "<tr>
<td class='form'>
<img src='images/poll.gif' width='$width' height='10' border='1'></img> $percentage%
</td>
</tr>
<tr>
<td class='form' style='padding-bottom: 5px;'>
$answer
</td>
</tr>
";
}
echo "</table>
based on $total_votes votes
";
}
echo "</td>
</tr>
</table>
";
}
?>
If it helps this is where I got the code from:
http://weblog.f2o.org/
Thanks