Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1957

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?php (no replies)

$
0
0
Can anyone tell me why I get this error?


<?php

$host="localhost";
$username="a1116279_vote";
$password="bat1234";
$db_name="a1116279_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 = "www.votecf.tk";
break;

case 2:
$url = "www.votecf2.tk";
break;

case 3:
$url = "www.votecf3.tk";
break;

default: die("Error!"); break;
}
}
return $url;
}

?>

Viewing all articles
Browse latest Browse all 1957

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>