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)) Quote Link to comment 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. Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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: ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 You missed a }. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 18, 2008 Author Share Posted May 18, 2008 BUMP Quote Link to comment 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. >_> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 18, 2008 Author Share Posted May 18, 2008 Still blank if I log in. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.