shiv-patel82
New Member
- Messages
- 4
- Reaction score
- 0
- Points
- 0
this is the error
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bama/public_html/vote.php on line 41
Unable to get number of entries: Table 'bama_smf.Votes' doesn't exist
this is the php.
the html to run vote.php
<form name="form" method="post" action="vote.php">
Username: <input name="username" type="text" id="username">
Vote # <select name="votenum">
<option value="1">1</option>
<option value="3">2</option>
</select><br/><br/>
<input type="submit" value="Submit"/>
</form>
I really need to fix this fast. And i dont know how i got the mysql database info correct
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bama/public_html/vote.php on line 41
Unable to get number of entries: Table 'bama_smf.Votes' doesn't exist
this is the php.
Code:
<?php
$host="localhost";
$username="bama_envypvp";
$password="mypass...";
$db_name="bama_vote";
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$username=$_POST['username'];
$voteid = ($_POST['votenum']);
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
if(clean_requests($time))
{
if(vote_entries($ip) == 0)
{
mysql_query("INSERT INTO Votes (username, ip, time, recieved) VALUES ('$username', '$ip', '$time', '0')", $link) or die("An internal error has occured please try again later.<br/>To go back click <a href='index.php'><b>HERE</b></a>");
header("Location: ".votenow($voteid)."");
}
else
{
die("You have already voted once today<br/>To go back click <a href='index.php'><b>HERE</b></a>");
}
}
else
{
die("An internal error has occured please try again later.<br/>To go back click <a href='index.php'><b>HERE</b></a>");
}
function clean_requests($time)
{
$query = mysql_query ( "SELECT * FROM Votes");
$i = 0;
while($row = mysql_fetch_array($query))
{
$i++;
$timerequested = $row['time'];
if($time-$timerequested > 12*3600)
{
if (!mysql_query( "DELETE FROM Votes WHERE time='$timerequested'"))
{
return false;
}
}
}
return true;
}
function vote_entries($ip)
{ $entries = mysql_query ( "SELECT * FROM Votes WHERE ip = '$ip'" );
if ( !$entries ) {
die ( "Unable to get number of entries: " . mysql_error () );
}
return mysql_num_rows ( $entries );
}
function votenow($votenum)
{
$url = "";
if($votenum)
{
switch($votenum)
{
case 1:
$url = "[URL]http://www.rune-server.org/top.php?act=vote&sod=4275[/URL]";
break;
case 2:
$url = "[URL]http://www.runelocus.com/toplist/index.php?action=vote&id=26893[/URL]";
break;
case 3:
$url = "[URL]http://www.moparscape.org/serverstatus.php?action=up&server=64.139.94.174[/URL]";
break;
default: die("Error!"); break;
}
}
return $url;
}
?>
the html to run vote.php
<form name="form" method="post" action="vote.php">
Username: <input name="username" type="text" id="username">
Vote # <select name="votenum">
<option value="1">1</option>
<option value="3">2</option>
</select><br/><br/>
<input type="submit" value="Submit"/>
</form>
I really need to fix this fast. And i dont know how i got the mysql database info correct