Jump to content

[SOLVED] mysql_num_rows error


Bopo

Recommended Posts

Hi

 

Well this is probably one of those silly errors that sometimes you just can't see, I have tried troubleshooting but I still can't find the problem, I get:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result

 

So therefore I used to the following code, however I always get the 'Missing ;' error, which is weird

 

if(!$result){die(mysql_error();}

 

Anyway, here's my code:

<form id="form1" name="form1" method="post" action="login.php">
  <p>
    <label>Username:
      <input type="text" name="username" id="Username" />
    </label>
  </p>
  <p>
    <label>Password:
      <input type="text" name="password" id="Password" />
    </label>
  </p>
  <p> </p>
  <p>
    <label>
      <input type="submit" name="submit" id="Login" value="Login" />
    </label>
  </p>
</form>
<?php

if(isset($_POST['submit'])) {

$username = $_POST['username'];
$password = $_POST['password'];



include("../createadmin/adminconnect.php");

$sql = "SELECT username, password FROM adminlogin WHERE username = '$username' AND password '$password'";
$result = mysql_query($sql, $connection);

echo "$sql";		



if(mysql_num_rows($result)) {
$_SESSION['loggedin'] = 1;
header('Location: http://www.website.com/admin/admin.php');
exit();}
else {
	header('Location: http://www.website.com/login.php?error1');
	exit();}

// if(!$result){die(mysql_error();}


}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/150375-solved-mysql_num_rows-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.