jwk811 Posted January 29, 2007 Share Posted January 29, 2007 [code] $id = session_id(); $ip = $_SERVER['REMOTE_ADDR']; $sql = "SELECT FROM polls WHERE id = '$id' or ip = '$ip'"; $result = mysql_query($sql); $rows = mysql_num_rows($result); if($rows > 0){ echo "One vote per person, sorry"; } else{ $vote = $_POST['rodent']; $poll = "feed"; $sql = "INSERT INTO polls(id, ip, vote, poll, date) VALUES('$id', '$ip', '$vote', '$poll', NOW())"; $result = mysql_query($sql); }[/code]why am i getting that error? Link to comment https://forums.phpfreaks.com/topic/36218-mysql_num_rows-invalid-argument/ Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 Change [code]$sql = "SELECT FROM polls WHERE id = '$id' or ip = '$ip'";[/code] to [code]$sql = "SELECT * FROM polls WHERE id = '$id' or ip = '$ip'";[/code] Link to comment https://forums.phpfreaks.com/topic/36218-mysql_num_rows-invalid-argument/#findComment-172057 Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 And to catch these errors earlier, do:$result = mysql_query($sql) OR die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/36218-mysql_num_rows-invalid-argument/#findComment-172059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.