Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 05-27-2012, 12:37 AM   #1
Join Date: Apr 2012
Posts: 13
Default login.php help

I am creating login form for first time and struck with following code:
PHP Code:


$username $_POST['username']; 

$password $_POST['password']; 


$connect =mysql_connect("mysql10.000webhost.com","a9714196_jas","bawamano83")or die ("couldnt connect to database"); 
mysql_select_db("a9714196_jas") or die ("coulnt find database"); 
$query mysql_query("SELECT * FROM 'user' WHERE username = '$username'" ); 
$numrows mysql_num_rows ($query); 
$numrows !=0
$row =mysql_fetch_assoc($query)); 
$dbusername $row['username']; 
$dbpassword $row['password']; 
         if (
"Login successful.<a href='membersarea.php'>Click here to enter the members area </a>"
$_SESSION ['username']=$dbusername
" Incorrect password"
" That username doesnot exist"); 

"Please enter a username and password"); 

The error message that I am getting is
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a9714196/public_html/login.php on line 21
jaspindermukar is offline   Reply With Quote
Old 05-27-2012, 07:45 PM   #2
davidj's Avatar
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256

Make sure your SQL is correct. Your tables are spelt correctly and are the correct case etc...

PHP Code:
SELECT FROM 'user' WHERE username '$username' 
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 05-28-2012, 01:59 AM   #3
edbr's Avatar
Join Date: Aug 2005
Location: Bali
Posts: 11,192

seems not to like if($numrows !=0)

if ($numrows > 0) {
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:30 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com