html - PHP/SQL mysql_num_rows() error -
this question has answer here:
i'm having issues executing code: http://tinyurl.com/m9zoscy sorry had put on google drive stackoverflow being fussy code... annnyway i'm having issues on line 18. ideas?
this code:
<link rel="stylesheet" type="text/css" href="style.css" /> <link href='http://fonts.googleapis.com/css?family=karla:400,700,700italic,400italic' rel='stylesheet' type='text/css'> <?php $filename = 'install.php'; if (file_exists($filename)) { echo ("<center><font color='red'><b>/install.php still exists<br> after installing please delete install.php</center></font></b>"); } else { if (isset($_post['login'])){ include('config.php'); if (!mysql_connect($host, $username, $password)) die("can't connect database"); if (!mysql_select_db($db_name)) die("can't select database"); $myusername=$_post['myusername']; $mypassword=$_post['mypassword']; $sql="select * $tbl_name username='$myusername' , password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count >= 1){ session_register("myusername"); session_register("mypassword"); header("location: index.php"); } else { echo "<center><font color='red'><b>wrong username or password</center></font></b>"; } } ?> <br> <form method="post" action=""><td> <table width="325" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#212121"> <td><table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#404040"></td> <tr colspan="3"><strong><center> <font color="ececec"> admin login </font></center></strong></tr> <tr> <td> <font color="ececec">username </font><input name="myusername" type="text" id="myusername"> <font color="ececec">password </font><input name="mypassword" type="password" id="mypassword"> </td> <center><td><input type="submit" name="login" value="login"></td></center> </table></table> </form> <?php } ?>
edit : $tbl_name not defined in code pasted.
else
your $result variable seems invalid...
try catching connection variable , give mysql_query :
<?php $link = mysql_connect($host, $username, $password); mysql_select_db($dbname, $link); $myusername=$_post['myusername']; $mypassword=$_post['mypassword']; $sql="select * $tbl_name username='$myusername' , password='$mypassword'"; $result = mysql_query($sql, $link); $num_rows = mysql_num_rows($result); ?>
or maybe select invalid... try doing echo , execute output in db program.
Comments
Post a Comment