fallenangel1983 Posted March 11, 2008 Share Posted March 11, 2008 I have tried some of the online tutorials that talk about user defined variables but i dont know what to do next. can anyone help? <?php // Connect to server and select databse. mysql_connect("localhost","root","") or die("cannot connect"); // username and password sent from sign up form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM users WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1) { while($row=mysql_fetch_row($result)) { $username = $row[0]; $password = $row[1]; $idType = $row[2]; if($idType==1) { session_start(); header("location:Users.html"); } elseif($idType==2) { session_start(); header("location:Admin.html"); } elseif($idType==3) { session_start(); header("location:Management.html"); } } } else { echo "Wrong Username or Password <br><a href='./LoginPage.php'>Go Back</a>"; } ?> Link to comment https://forums.phpfreaks.com/topic/95636-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/ Share on other sites More sharing options...
trq Posted March 11, 2008 Share Posted March 11, 2008 Change this... $result=mysql_query($sql); to... $result=mysql_query($sql) or die(mysql_error() ."<br />" . $sql); What do you get? Link to comment https://forums.phpfreaks.com/topic/95636-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-489615 Share on other sites More sharing options...
fallenangel1983 Posted March 11, 2008 Author Share Posted March 11, 2008 brilliant thanks very much i have been struggling with that for hours. cheers again Link to comment https://forums.phpfreaks.com/topic/95636-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-489620 Share on other sites More sharing options...
redarrow Posted March 11, 2008 Share Posted March 11, 2008 use session start once on top of page........ <?php session_start(); ?> dont need all theose session_start's mate.......... Link to comment https://forums.phpfreaks.com/topic/95636-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-489626 Share on other sites More sharing options...
fallenangel1983 Posted March 11, 2008 Author Share Posted March 11, 2008 oh i didnt know that. appreciated. cheers again. above and beyond the call of duty mate nice one Link to comment https://forums.phpfreaks.com/topic/95636-warning-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resourc/#findComment-489632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.