473,788 Members | 3,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql_num_rows( ) argument is not being recognized, any help would be appreciated

3 New Member
Hi everyone,

I've recently begun learning PHP and it looks like I took on too much so soon.

I'm attempting to fix a php script that detects whether or not a person is Eligible to join a tournament or not when they register and attempt to join. I'm doing it locally at the moment so i don't need to upload every 5 minutes. Any assistance would be appreciated.

On register.php, I am receiving the following error:

Expand|Select|Wrap|Line Numbers
  1. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/vehement/public_html/ladder/join.php on line 935

Here is the code for joining the tournament:

Expand|Select|Wrap|Line Numbers
  1. function check_if_ladder_under_usergroup($ladderid, $teamid=NULL, $userid=NULL){
  2. global $config;
  3.  
  4. $sql = mysql_query("SELECT * FROM groupstable WHERE `ladderon` = ".$ladderid);
  5. if(mysql_num_rows($sql) > 0){
  6.     //ladder is restricted
  7.     if(empty($teamid) && empty($userid)) return false; //return that is ladder is restricted
  8.  
  9.     $ginfo = mysql_fetch_assoc($sql);
  10.     if(mysql_num_rows(mysql_query("SELECT * FROM groupsmembers WHERE `groupid` = ".$ginfo['id']." AND `memberid`=".intval($userid)."")) > 0){
  11.         return true;
  12.     }elseif(empty($teamid)){
  13.         return false;
  14.     }else{
  15.         return (mysql_num_rows(mysql_query("SELECT * FROM groupsmembers WHERE `groupid` = ".$ginfo['id']." AND `teamid`=".intval($teamid)."")) > 0);
  16.     }
  17. }
  18. return true; //no restirction
  19. }

On the "if(mysql_num_r ows($sql) > 0)" part, I don't understand why it's not a valid argument. Thanks for any advise you can provide!
Oct 20 '09 #1
4 3630
Dormilich
8,658 Recognized Expert Moderator Expert
and once again the standard error …

mysql_query() returns false if something’s gone wrong, and false is not a valid resource.

standard check:
Expand|Select|Wrap|Line Numbers
  1. $resource = mysql_query($sql) or die(mysql_error());
Oct 20 '09 #2
seigaku
3 New Member
hi Dormilich,

thank you for the help. it looks like the error is still there even with the new code...
line 935 is:

Expand|Select|Wrap|Line Numbers
  1.  if(mysql_num_rows($sql) > 0){ 
Oct 20 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
what does
Expand|Select|Wrap|Line Numbers
  1. var_dump($sql);
just before the mysql_num_rows( ) output?
Oct 20 '09 #4
seigaku
3 New Member
hi again,

after spending a lot of time on this with my friend, it seems that $ladderid is returning no value. from the code, it seems it is not adding on ?ladder=1 at the end of the url for the sql database to grab. the website works though, without the restriction so my friend put in a bypass to not see the error but will display the rest of the page.

for reference to anyone else who has such an issue, here is the new code for the section:

Expand|Select|Wrap|Line Numbers
  1. function check_if_ladder_under_usergroup($tournamentid, $teamid=NULL, $userid=NULL){
  2. global $config;
  3.  
  4. $sql = mysql_query("SELECT * FROM groupstable WHERE `ladderon` = ".$ladderid);
  5.  
  6. if($sql !=false)
  7. {
  8.  
  9. if(mysql_num_rows($sql) > 0){
  10. //ladder is restricted
  11.  
  12. if(empty($teamid) && empty($userid)) return false; //return that is ladder is restricted
  13. $ginfo = mysql_fetch_assoc($sql);
  14. if(mysql_num_rows(mysql_query("SELECT * FROM groupsmembers WHERE `groupid` = ".$ginfo['id']." AND 
  15.  
  16. `memberid`=".intval($userid)."")) > 0){
  17. return true;
  18. }elseif(empty($teamid)){
  19. return false;
  20. }else{return (mysql_num_rows(mysql_query("SELECT * FROM groupsmembers WHERE `groupid` = ".$ginfo['id']." AND 
  21.  
  22. `teamid`=".intval($teamid)."")) > 0);
  23. }
  24. }
  25. }
  26. return true; //no restirction
  27. }
  28.  
thanks for all the help!
Oct 20 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2110
by: David Nikel | last post by:
I am attempting to create a login script. The following snippet of code: $query = "select * from auth where username='$username' and password=password('$password')"; $result = mysql_query($query, $db_conn); $num = mysql_num_rows($result); echo $num;
4
1754
by: Fish44 | last post by:
Ive got the following code which works great on my localserver, but when i upload it to my service provider i get an error "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /opt2/home3/mitas/public_html/register.php on line 86 It seems to be only this function mysql_num_rows() causing a problem, and the rest of the code works ok, and it adds data correctly.
7
1918
by: Dejan | last post by:
Hi Sorry for my terreble english. On my local (win) comp i have apache+mysql+php 4.05 I'm counting rows using mysql_num_rows function, and everything works fine. When i upload php file on server it says: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/optikara/public_html/crosun/izn/insert_form.php on line 80
2
18903
by: 00webman | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/scripts/07/view_users.php on line 15 Can anyone spot my error?!? Thanks. <?php # Script 7.6 - view_users.php (2nd version after Script 7.4) // This script retrieves all the records from the users table. $page_title = 'View the Current Users'; include ('./includes/header.html');
3
3919
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu"> <div class="boxhead" style="text-align:center;"> <strong>Menu</strong> </div> <br /> <?php require ('includes/db_conn.inc.php'); $query = "select * from menu order by item_order"; $result = mysql_query($query);
3
1584
The1corrupted
by: The1corrupted | last post by:
Okay, this has blown my entire perception of reality way out of order. First, a page was working and not five minutes later, I get this error, Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Vardaes\gendisp.php on line 66 and I made insignificant changes to the script before hand that had nothing to do with mysql_num_rows();... Here's line 66 $saynum=mysql_num_rows(mysql_query("SELECT `cn`...
4
7836
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the fields Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34 Sorry You failed to enter the correct old password I was wondering if anyone could help me, I have...
11
3720
matheussousuke
by: matheussousuke | last post by:
I'm having the following trouble: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mghosped/public_html/anuncieaki/lib/func_common.php on line 149 This is the line 149 for ($i=1; $i<mysql_num_rows($result); $i++ )
2
3231
by: macdalor | last post by:
Hi! I'm completely new to all dev and trying to put a website together using MySQLI and PHP; was running fine until I try to gather the DB content with the following script: <? $username="xxxxxx"; $password="xxxxxx"; $database="maxalien_davidloran"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts";
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.