Hack Forums
[PHP] PHP Login/Register | Login problem. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] PHP Login/Register | Login problem. (/showthread.php?tid=2123678)



PHP Login/Register | Login problem. - OsteeN - Jan 18, 2012

So, i got error in my php code at this line:

Code
//Counting table row
$count=mysql_num_rows($result);
mySQL error:
Code
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a5899566/public_html/checklogin.php on line 30

Heres the code that is interacted with the line:

Code
$sql = "SELECT * FROM $tbl_name WHERE username='$usern' and password='$passn'";
$result=mysql_query($sql);

//Counting table row
$count=mysql_num_rows($result);
Anyone help? :3


* - kalwat - Jan 18, 2012

$result=mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);

try that.


* - OsteeN - Jan 18, 2012

(Jan 18, 2012 06:08 PM)kalwat Wrote:  $result=mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);

try that.
Then it says this:

Code
Error: Query was empty with query



* - Reserve - Jan 18, 2012

Can you echo $results and post the contents?


* - OsteeN - Jan 18, 2012

(Jan 18, 2012 08:28 PM)IceGuru™ Wrote:  Can you echo $results and post the contents?

Nope i can't, all i get is the query thing i posted over those 2 posts.


* - BlueLight™ - Jan 18, 2012

Did you connect to your database before hand? Are your table names correct?


* - OsteeN - Jan 18, 2012

(Jan 18, 2012 10:20 PM)Counterworld Wrote:  Did you connect to your database before hand? Are your table names correct?

Yep, this is at login section. The register works fien, and it isnerts the details into the table.


* - Poppins - Jan 19, 2012

(Jan 18, 2012 06:11 PM)osteen Wrote:  Then it says this:

Code
Error: Query was empty with query

Use the variable in your script: $sql -_-


* - BlueLight™ - Jan 19, 2012

Try and make the "and" in the $sql statement capitals like "AND".