jonhmatthew Posted February 21, 2010 Share Posted February 21, 2010 Help!! - Im trying to display logged in user's row in table (not the whole table) - Please help me guys --error message-- Warning: Wrong parameter count for mysql_num_rows() in /misc/22/000/244/268/0/user/web/x2broadcasting.com/login_success.php on line 34 Invalid USer..... --------my code--------------- <? session_start(); if(!session_is_registered(myusername)){ header("location:home.php"); } ?> <html> <body> Login Successful </body> </html> <br><a href="http://x2broadcasting.com/loginhome.php" target="_top">Proceed Here</a> <br> or <br> <a href="http://www.x2broadcasting.com/logout.php" target="_top">Log Out</a>!<html> <body> <?php $username="jonhmatthew"; $password="*********"; $database="x2_2434451"; $localhost="sql8.bravehost.com"; mysql_connect($localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = mysql_query("SELECT * FROM Users WHERE username = '$username' and password = '$password'")or die("Error:" . mysql_error()); $rlt = mysql_fetch_array($query); $count = mysql_num_rows(); if($count == 1){ session_register("username"); $_SESSION['USERID'] = $rlt['id']; }else{ echo "Invalid USer....."; } $qry = mysql_query("SELECT * FROM Users WHERE id = '".$_SESSION['USERID']."'")or die("ERROR:" . mysql_error()); $rst = mysql_fetch_array($qry); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"><tr> <th><font face="Arial, Helvetica, sans-serif">Value1</font></th> <th><font face="Arial, Helvetica, sans-serif">Value2</font></th> <th><font face="Arial, Helvetica, sans-serif">Value3</font></th> <th><font face="Arial, Helvetica, sans-serif">Value4</font></th> <th><font face="Arial, Helvetica, sans-serif">Value5</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Production Appointments"); $f2=mysql_result($result,$i,"Available Commercials"); $f3=mysql_result($result,$i,"Now AIring"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr> <?php $i++; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/ Share on other sites More sharing options...
Alex Posted February 21, 2010 Share Posted February 21, 2010 You need to pass $query to mysql_num_rows (see the manual link). Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1015787 Share on other sites More sharing options...
jl5501 Posted February 21, 2010 Share Posted February 21, 2010 mysql_num_rows() takes a result set from mysql_query as a parameter $count = mysql_num_rows($query); in your code Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1015788 Share on other sites More sharing options...
jonhmatthew Posted February 21, 2010 Author Share Posted February 21, 2010 this helped , now my page is displaying "invalid user" as you can see under $count, how can I make this a valid user ?? Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1015791 Share on other sites More sharing options...
jonhmatthew Posted February 21, 2010 Author Share Posted February 21, 2010 my page is displaying "invalid user" as you can see under $count, how can I make this a valid user ?? -----my code----- $query = mysql_query("SELECT * FROM Users WHERE username = '$username' and password = '$password'")or die("Error:" . mysql_error()); $rlt = mysql_fetch_array($query); $count = mysql_num_rows($query ); if($count == 1){ session_register("username"); $_SESSION['USERID'] = $rlt['id']; }else{ echo "Invalid USer....."; } Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1015792 Share on other sites More sharing options...
jl5501 Posted February 21, 2010 Share Posted February 21, 2010 Well that suggests that your query is returning no rows for the criteria given, so you need to make sure that the username and password are what you expect them to be when going in to the query, and that a row with that username ans password, exists in the db Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1015800 Share on other sites More sharing options...
jonhmatthew Posted February 23, 2010 Author Share Posted February 23, 2010 I know, but I would like to return the person that goes to login's information....how would I output that person's information only? What name do I type in the username box? Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1016500 Share on other sites More sharing options...
jonhmatthew Posted February 23, 2010 Author Share Posted February 23, 2010 nevermind i got some help @ http://php.about.com/od/finishedphp1/ss/php_login_code.htm, thanx guys Quote Link to comment https://forums.phpfreaks.com/topic/192851-need-simple-help-warning-wrong-parameter-count/#findComment-1016512 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.