Cory94bailly Posted May 17, 2008 Share Posted May 17, 2008 Error I'm getting: <b>Warning</b>: mysql_fetch_array() [<a href='function.mysql-fetch-array'>function.mysql-fetch-array</a>]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in <b>/home/content/m/a/r/markbailly/html/fcs/includes/loggedin.php</b> on line <b>15</b><br /> <br /> <b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/content/m/a/r/markbailly/html/fcs/includes/loggedin.php</b> on line <b>15</b><br /> Whole php code: <? if(isset($_COOKIE['ID_fcs_member'])) { //Connect to Members DB mysql_connect('***', '***', '***) or die(mysql_error()); mysql_select_db('***') or die(mysql_error()); //Look for the cookies $username1 = $_COOKIE['ID_fcs_member']; $pass1 = $_COOKIE['Key_fcs_member']; $username2 = $_COOKIE['ID_fcs_team']; $pass2 = $_COOKIE['Key_fcs_team']; $check1 = mysql_query("SELECT * FROM members WHERE username = '$username1'")or die(mysql_error()); $check2 = mysql_query("SELECT * FROM team WHERE username = '$username2'")or die(mysql_error()); while(mysql_fetch_array($check1, $check2)) { //If the cookie exists, show the "Logout" button. { ?> <a href="logout.php">Logout</a> <? } } } else //If the cookie does not exist, show the "Login" button. { ?> <a href="login.php">Login</a> <img src="images/splitter.gif" class="splitter" alt="" /> <a href="register.php">Register</a> <? } ?> Line 15: while(mysql_fetch_array($check1, $check2)) Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/ Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 You can't fetch two row sets in that manner. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543539 Share on other sites More sharing options...
Cory94bailly Posted May 17, 2008 Author Share Posted May 17, 2008 You can't fetch two row sets in that manner. Oh.. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543541 Share on other sites More sharing options...
Cory94bailly Posted May 17, 2008 Author Share Posted May 17, 2008 Explainations on how to do it would help Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543555 Share on other sites More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 if (mysql_numrows($check1) > 0) { // a record was found with the first query } else if (mysql_numrows($check2) > 0) { // a record was found with the first query } personally, i'd run the first query, see if there are any records, then run the second query. no need to do both unless you need to do it that way. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543572 Share on other sites More sharing options...
Cory94bailly Posted May 17, 2008 Author Share Posted May 17, 2008 if (mysql_numrows($check1) > 0) { // a record was found with the first query } else if (mysql_numrows($check2) > 0) { // a record was found with the first query } personally, i'd run the first query, see if there are any records, then run the second query. no need to do both unless you need to do it that way. I now get this: <b>Parse error</b>: syntax error, unexpected $end in <b>/home/content/m/a/r/markbailly/html/fcs/includes/loggedin.php</b> on line <b>38</b><br /> My full code: <? if(isset($_COOKIE['ID_fcs_member'])) { //Connect to Members DB mysql_connect('***', '***', '***') or die(mysql_error()); mysql_select_db('***') or die(mysql_error()); //Look for the cookies $username1 = $_COOKIE['ID_fcs_member']; $pass1 = $_COOKIE['Key_fcs_member']; $username2 = $_COOKIE['ID_fcs_team']; $pass2 = $_COOKIE['Key_fcs_team']; $check1 = mysql_query("SELECT * FROM members WHERE username = '$username1'")or die(mysql_error()); $check2 = mysql_query("SELECT * FROM team WHERE username = '$username2'")or die(mysql_error()); if (mysql_numrows($check1) > 0) { // a record was found with the first query } else if (mysql_numrows($check2) > 0) { // a record was found with the first query { //If the cookie exists, show the "Logout" button. { ?> <a href="logout.php">Logout</a> <? } } } else //If the cookie does not exist, show the "Login" button. { ?> <a href="login.php">Login</a> <img src="images/splitter.gif" class="splitter" alt="" /> <a href="register.php">Register</a> <? } ?> Line 38: ?> Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543627 Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 You missed a }. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543629 Share on other sites More sharing options...
Cory94bailly Posted May 17, 2008 Author Share Posted May 17, 2008 You missed a }. Ok.. I just tried putting it at the end and the script showed nothing.. Where should I put it? Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543631 Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 Wherever you want the IF statement to stop, lmfao. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543634 Share on other sites More sharing options...
Cory94bailly Posted May 17, 2008 Author Share Posted May 17, 2008 Wherever you want the IF statement to stop, lmfao. Well.. I'm not good at php so I didn't know.......... Here's my script now: <? if(isset($_COOKIE['ID_fcs_member'])) { //Connect to Members DB mysql_connect('p41mysql145.secureserver.net', 'cory_fcs', 'Sils1234') or die(mysql_error()); mysql_select_db('cory_fcs') or die(mysql_error()); //Look for the cookies $username1 = $_COOKIE['ID_fcs_member']; $pass1 = $_COOKIE['Key_fcs_member']; $username2 = $_COOKIE['ID_fcs_team']; $pass2 = $_COOKIE['Key_fcs_team']; $check1 = mysql_query("SELECT * FROM members WHERE username = '$username1'")or die(mysql_error()); $check2 = mysql_query("SELECT * FROM team WHERE username = '$username2'")or die(mysql_error()); if (mysql_numrows($check1) > 0) { // a record was found with the first query } else if (mysql_numrows($check2) > 0) { // a record was found with the first query { //If the cookie exists, show the "Logout" button. { ?> <a href="logout.php">Logout</a> <? } } } } else //If the cookie does not exist, show the "Login" button. { ?> <a href="login.php">Login</a> <img src="images/splitter.gif" class="splitter" alt="" /> <a href="register.php">Register</a> <? } ?> I am getting no actual "errors".. But when I am logged out, it works.. if you log in, it just shows nothing. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543636 Share on other sites More sharing options...
Cory94bailly Posted May 18, 2008 Author Share Posted May 18, 2008 BUMP Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-543947 Share on other sites More sharing options...
DarkWater Posted May 18, 2008 Share Posted May 18, 2008 1) Annoying bumps are annoying. 2) I think it's mysql_num_rows and not mysql_numrows. >_> Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-544225 Share on other sites More sharing options...
Cory94bailly Posted May 18, 2008 Author Share Posted May 18, 2008 1) Annoying bumps are annoying. 2) I think it's mysql_num_rows and not mysql_numrows. >_> 1.) Sorry 2.) Ooh, nice fine.. I'll try it now. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-544226 Share on other sites More sharing options...
Cory94bailly Posted May 18, 2008 Author Share Posted May 18, 2008 Still blank if I log in. Link to comment https://forums.phpfreaks.com/topic/106061-solved-quotsupplied-argument-is-not-a-valid-mysql-result-resourcequot/#findComment-544228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.