Strange SQL Error
Posted: Tue Mar 13, 2007 3:27 pm
I'm creating a simple vote script where the system logs the IP in a column,
if you vote it logs your IP in a column in the vote table and when you try to vote again
it checks if your IP is already in the table.
But I keep getting:
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 '.253.130' at line 1
my code:
if you vote it logs your IP in a column in the vote table and when you try to vote again
it checks if your IP is already in the table.
But I keep getting:
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 '.253.130' at line 1
my code:
Code: Select all
<?php
if (isset($_GET['vote'])) {
$m_id = preg_replace('/[^0-9\_]/', '', $_GET['vote']);
$ip = $_SERVER['REMOTE_ADDR'];
$result = mysql_query("SELECT * FROM votes WHERE ip=$ip ") or die(mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows > 0) { echo "<div id=voterr>You already voted</div>"; }
else {
$result = mysql_query("SELECT * FROM users where m_id=$m_id ") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$m_votes = $row['m_votes'];
// code logging the vote }
}
}