froboz Posted October 20, 2008 Share Posted October 20, 2008 I've run into a bit of a wall on one of my projects, I don't know if I'm just being blind on my own code or what because I cannot wrap my head around this one: $result = "SELECT * FROM v_disciplines WHERE username = 'USERNAME' AND discipline = '".$discipline."'"; $doublet_check = mysql_num_rows($result); gives the following error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\php\process_character.php on line 40 my table v_disciplines exists with the fields player, disciplines and level. I've used it before with no problem and am using it in the current script with no problem except for here. 'USERNAME' is a placeholder during developement. Link to comment https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/ Share on other sites More sharing options...
aeonsky Posted October 20, 2008 Share Posted October 20, 2008 You need to perform a query on the SQL statement. Here's the PHP Manual's example... <?php $link = mysql_connect("localhost", "mysql_user", "mysql_password"); mysql_select_db("database", $link); //PERFORM QUERY $result = mysql_query("SELECT * FROM table1", $link); //PERFORM QUERY $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; ?> Link to comment https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/#findComment-669806 Share on other sites More sharing options...
froboz Posted October 20, 2008 Author Share Posted October 20, 2008 Thank you for the reply, this is of course true and a miss by me. however: $result = mysql_query("SELECT * FROM v_disciplines WHERE username = 'USERNAME' AND discipline = '".$discipline."'"); $doublet_check = mysql_num_rows($result); still produces the same error. Link to comment https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/#findComment-669808 Share on other sites More sharing options...
aeonsky Posted October 20, 2008 Share Posted October 20, 2008 You said... my table v_disciplines exists with the fields player, disciplines and level. I've used it before with no problem and am using it in the current script with no problem except for here. 'USERNAME' is a placeholder during developement. So shouldn't you change it to... $result = "SELECT * FROM v_disciplines WHERE username = 'USERNAME' AND disciplines = '".$discipline."'"; Link to comment https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/#findComment-669812 Share on other sites More sharing options...
froboz Posted October 20, 2008 Author Share Posted October 20, 2008 no, sorry that was a typo on my side. The field is called discipline as refered to in the mysql_query() Link to comment https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/#findComment-669815 Share on other sites More sharing options...
froboz Posted October 20, 2008 Author Share Posted October 20, 2008 I managed to solve it by copy pasting from a previous code I made, suppose there was some sort of typo in there or something. Might never know. Thank you very much for taking your time to try and help me solve this problem. Link to comment https://forums.phpfreaks.com/topic/129191-solved-simple-doublet-check-is-failing/#findComment-669952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.