require($boardpath."conf_global.php");
$db = mysql_connect($INFO['sql_host'],$INFO['sql_user'],$INFO['sql_pass']) or mysqlfail();
mysql_select_db($INFO['sql_database'],$db) or mysqlfail();
//All set. Lets go before I get bored. :P
$thequery = mysql_query("SELECT m.id AS id, m.member_login_key AS password, m.name AS name, m.mgroup AS mgroup, m.new_msg AS new_msg, m.show_popup AS show_popup, g.g_id AS g_id, g.g_access_cp AS g_access_cp FROM {$INFO['sql_tbl_prefix']}members m LEFT JOIN {$INFO['sql_tbl_prefix']}groups g ON ( g.g_id = m.mgroup) WHERE id='{$member_id}'",$db) or mysqlfail();
//The only query needed. :)
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\gcms\sources\test.php on line 46
I'm stuck. It seems like when I removed the code the script is able to run without errors (BUT no repeat region).
The repeat region codes are generated by Dreamweaver.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\gcms\sources\test.php on line 46
Most of the time this indicates that your query isn't returning any rows but that you're still attempting to do something with them.
require($boardpath."conf_global.php");
$db = mysql_connect($INFO['sql_host'],$INFO['sql_user'],$INFO['sql_pass']) or mysqlfail();
mysql_select_db($INFO['sql_database'],$db) or mysqlfail();
//All set. Lets go before I get bored. :P
$thequery = mysql_query("SELECT m.id AS id, m.member_login_key AS password, m.name AS name, m.mgroup AS mgroup, m.new_msg AS new_msg, m.show_popup AS show_popup, g.g_id AS g_id, g.g_access_cp AS g_access_cp FROM {$INFO['sql_tbl_prefix']}members m LEFT JOIN {$INFO['sql_tbl_prefix']}groups g ON ( g.g_id = m.mgroup) WHERE id='{$member_id}'",$db) or mysqlfail();
//The only query needed. :)
if (isset($member_id) && $pass_hash == $member['password']) {
$_SESSION['member_id'] = $member['id'];
}
echo $_SESSION['member_id'] = $member['id'];
?>
The primary function of the above code is to validate the user using the password hash stored in the cookie with the key hash in the database and assign a session 'member_id' to it.
You also rely on the member_id cookie in your query. First check if it's set, and then run the query. I'd also make sure it doesn't contain unallowed content. If it's a unique ID, I'd suggest using intval().
require($boardpath."conf_global.php");
$db = mysql_connect($INFO['sql_host'],$INFO['sql_user'],$INFO['sql_pass']) or mysqlfail();
mysql_select_db($INFO['sql_database'],$db) or mysqlfail();
//All set. Lets go before I get bored. :P
$thequery = mysql_query("SELECT m.id AS id, m.member_login_key AS password, m.name AS name, m.mgroup AS mgroup, m.new_msg AS new_msg, m.show_popup AS show_popup, g.g_id AS g_id, g.g_access_cp AS g_access_cp FROM {$INFO['sql_tbl_prefix']}members m LEFT JOIN {$INFO['sql_tbl_prefix']}groups g ON ( g.g_id = m.mgroup) WHERE id='{$member_id}'",$db) or mysqlfail();
//The only query needed. :)
if (isset($member_id) && $pass_hash == $member['password']) {
$_SESSION['member_id'] = $member['id'];
}
echo $_SESSION['member_id'] = $member['id'];
?>
Managed to echo out $_SESSION['member_id'] = $member['id'] successfully with my member id value. But after I've added the 'cookie->validation->session' codes, the follow error starts to occur.. BUT, there isn't any problems with the Repeat Regions codes generated by Dreamweaver.
Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\gcms\sources\test.php on line 46
If a query fails due to syntax errors..., the result it returns will be a false value instead of a result resource. The error you are getting indicates that the query could not be executed by the mysql server.
If a mysql_fetch_array(...) is used on a query that succeeded, but there were no rows in the result set, it returns a false value. If there was at least one row remaining in the result set, it returns a row from the result set. But, your code is not getting to this point.
You are apparently using a custom mysql error function - ... or mysqlfail();. This should test for and display the actual error returned by the mysql query. If it is not, I recommend replacing it with -
PHP Code:
or die('Query Failed: ' . mysql_error());
I also recommend that you form the query string in a variable and then echo it out to make sure it contains the expected contents.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???