ObscureProtection
-
Posts
6 -
Joined
-
Last visited
Posts posted by ObscureProtection
-
-
ah, you're right. Fixed it, but it's still throwing the same error.
-
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/op/public_html/test.php on line 71
<?php $host = "blahblah.net"; $data = "thisIsData"; $user = "PHPhelp"; $pass = "help"; $sql = mysql_connect("$host", "$user", "$pass"); mysql_select_db("$data", $sql); if(isset($_POST['1']) || isset($_POST['2']) || isset($_POST['3']) || isset($_POST['4']) || isset($_POST['5'])) { if(!empty($_POST['1'])) $user_rating = $_POST['1']; if(!empty($_POST['2'])) $user_rating = $_POST['2']; if(!empty($_POST['3'])) $user_rating = $_POST['3']; if(!empty($_POST['4'])) $user_rating = $_POST['4']; if(!empty($_POST['5'])) $user_rating = $_POST['5']; $ip = safeEntry(trim(getenv("REMOTE_ADDR"))); $date = date('Y-m-d H:i:s'); $result = mysql_query("select ip from ban where ip='$ip'", $sql); Line 71: $num_rows = mysql_num_rows($result); if($num_rows == 0) mysql_query("insert into rate values(null, $entry,'$date', $ip, $user_rating)"); } ?>
-
Yes, I sectioned off the part that was throwing the error, but further above on test.php I have:
include "mysqlc.php";
which calls:
<?php $host = "blahblah.net"; $data = "thisIsData"; $user = "PHPhelp"; $pass = "help"; $sql = mysql_connect("$host", "$user", "$pass"); $db = mysql_select_db("$data") or die (mysql_error()); ?>[/cod]
-
I'm getting an: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/op/public_html/test.php on line 70
if(isset($_POST['1']) || isset($_POST['2']) || isset($_POST['3']) || isset($_POST['4']) || isset($_POST['5'])) { if(!empty($_POST['1'])) $user_rating = $_POST['1']; if(!empty($_POST['2'])) $user_rating = $_POST['2']; if(!empty($_POST['3'])) $user_rating = $_POST['3']; if(!empty($_POST['4'])) $user_rating = $_POST['4']; if(!empty($_POST['5'])) $user_rating = $_POST['5']; $ip = safeEntry(trim(getenv("REMOTE_ADDR"))); $date = date('Y-m-d H:i:s'); Line 70: if(mysql_num_rows(mysql_query("select ip from ban where ip='$ip'")) == 0) mysql_query("insert into rate values(null, $entry,'$date', $ip, $user_rating)"); }
I don't understand why it's not working...? It's a code for a voting system (1-5 scale). I'm trying to check to see if the voter IP is banned, if it isn't then insert the voting values.
PHP version 5.2.3
MySQL version 4.1.22
[SOLVED] mysql_num_rows(): supplied argument is not a valid?
in PHP Coding Help
Posted
yup I did remove the quotes for $pass and $user prior, but it's the '$ip' that did it, ahh thanks so much you're the greatest!