Customizing SMF > SMF Coding Discussion

MySQL Warning When Dealing With the smf_members Table

(1/4) > >>

bneacetp:
I am trying to access the smf_members table to check and see how many members are in a particular ID_GROUP.  The data is correctly retrieved, but I get at least some variation of the following three warnings showing up at the end of the pages that try to access the smf_members table:


--- Quote ---Warning: mysql_query(): 10 is not a valid MySQL-Link resource in [...]\forum\Sources\Subs.php on line 316

Warning: mysql_affected_rows(): 10 is not a valid MySQL-Link resource in [...]\forum\Sources\Subs.php on line 331

Warning: mysql_query(): 10 is not a valid MySQL-Link resource in [...]\forum\Sources\Subs.php on line 316
--- End quote ---


Basically what I am trying to do is to:

1. Connect to and select the forum database.
2. Run a query:
--- Code: ---$query = 'SELECT ID_MEMBER FROM smf_members WHERE ID_GROUP = ' . $row['group_id'] . ';';
--- End code ---
3. Close the connection.
4. Use mysql_num_rows() on the returned result stored in a variable to see how many users are part of the particular group.

Any idea as to what is causing the warnings and any possible workarounds?

Tony Reid:
Shouldnt it be something like this....

$query = "SELECT ID_MEMBER FROM smf_members WHERE ID_GROUP = ' . $row['group_id'] . ';";

bneacetp:

--- Quote from: Tony on April 19, 2006, 03:40:29 AM ---Shouldnt it be something like this....

$query = "SELECT ID_MEMBER FROM smf_members WHERE ID_GROUP = ' . $row['group_id'] . ';";

--- End quote ---

That code generates an error.  The code I have in my first post on this topic works but it generates the the kind of warnings mentioned above.  The code seems to work, but I don't understand why the warnings come up. 

Leipe Po:
are you using db_query(smf own query thingy) or mysql_query()?
if you use mysql, change the mysql bit to db so
mysql_query => db_query
mysql_affected_rows => db_affected_rows

ect. ect.

als make sure you use __FILE__,__LINE__ inside querys, so it would be like:

db_query("SELECT ID_MEMBER FROM smf_members WHERE ID_GROUP = ' . $row['group_id'] . ', __FILE__,__LINE__");

or something close to that

bneacetp:
When I try the suggestion above, I get:


--- Quote ---Warning: Cannot modify header information - headers already sent by (output started at .....\staff_avail.php:10) in .....\forum\Sources\Subs.php on line 3176

Warning: Cannot modify header information - headers already sent by (output started at .....\staff_avail.php:10) in .....\forum\Sources\Subs.php on line 3177

Warning: Cannot modify header information - headers already sent by (output started at .....\staff_avail.php:10) in .....\forum\Sources\Subs.php on line 3183

Warning: Cannot modify header information - headers already sent by (output started at .....\staff_avail.php:10) in .....\forum\Sources\Subs.php on line 3186

Warning: template_main_above(../ssi/core_settings.php): failed to open stream: No such file or directory in .....\forum\Sources\Load.php(1607) : eval()'d code on line 54

Warning: template_main_above(): Failed opening '../ssi/core_settings.php' for inclusion (include_path='.;c:\php4\pear') in .....\forum\Sources\Load.php(1607) : eval()'d code on line 54

Warning: template_main_above(../ssi/header_scripts.php): failed to open stream: No such file or directory in .....\forum\Sources\Load.php(1607) : eval()'d code on line 135

Fatal error: template_main_above(): Failed opening required '../ssi/header_scripts.php' (include_path='.;c:\php4\pear') in .....\forum\Sources\Load.php(1607) : eval()'d code on line 135

--- End quote ---

I am closer to the end result that I want just using mysql_query but I get those three pesky warnings that I mentioned earlier in this post.  Any suggestions? 

Navigation

[0] Message Index

[#] Next page

Go to full version