Dear LCKB Community :3
I want to start to learn "MySQL"...
Now I have found on YouTube a video
(How To make a Login and Register System in PHP) and is everything okay so far..., nevertheless, if I want to connect with the DB a mistake always comes although everything is properly:S
Login Control (only PHP):
<title>Login</title>
<form action="login2.php" method="post">
<table>
<Tr>
<td>Username: </td>
<td><input type="text" name="username" ></td>
</Tr>
<Tr>
<td>Password: </td>
<td><input type="password" name="password" ></td>
</Tr>
<Tr>
<td><input type="submit" name="loginbtn" value="Login"></td>
<td><a href="newregister.php">Register</a></td>
</Tr>
</table>
Login Script (Not yet ready but with Error):
<?php
$user_id = $_POST['username'];
$passwd = $_POST['password'];
if($user_id && $passwd){
$connect = mysql_connect("localhost","root","");
mysql_select_db("ep1_db_auth");
$query = mysql_query("SELECT * FROM bg_user WHERE username='$user_id' && password='$passwd'");
$numrows = mysql_num_rows($query);
echo("$numrows");
}
else
echo("Bitte geben sie ihre Daten ein.");
?>
I get this mistake over and over again; "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\login2.php on line 9"
Hope somebody can help me :S
~SmoGG.
Posts: 31
Threads: 1
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Sep 2011
Reputation:
0
Error :
$query = mysql_query("SELECT * FROM bg_user WHERE username='$user_id' && password='$passwd'");
Changed to this
$query = mysql_query("SELECT * FROM bg_user WHERE username='$user_id' AND password='$passwd'");
Correct me if i'm wrong
Error :
$query = mysql_query("SELECT * FROM bg_user WHERE username='$user_id' && password='$passwd'");
Changed to this
$query = mysql_query("SELECT * FROM bg_user WHERE username='$user_id' AND password='$passwd'");
Correct me if i'm wrong
Hmmm nope same Problem :S
Here the Video (look 4:30-5:30 maybe) -
Posts: 31
Threads: 1
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Sep 2011
Reputation:
0
You are working with bg_user of newproject_db_suth??
mysql_select_db("ep1_db_auth");
so yes
Posts: 31
Threads: 1
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Sep 2011
Reputation:
0
ok
$query = mysql_query("SELECT * FROM bg_user WHERE user_id='$user_id' && passwd='$passwd'");
hmm now another error :
Notice: Undefined index: user_id in D:\xampp\htdocs\login2.php on line 2
Notice: Undefined index: passwd in D:\xampp\htdocs\login2.php on line 3
<?php
$user_id = $_POST['username'];
$passwd = $_POST['password'];
if($user_id && $passwd){
$connect = mysql_connect("localhost","root","");
mysql_select_db("ep1_db_auth");
$query = mysql_query("SELECT * FROM bg_user WHERE user_id='$user_id' && passwd='$passwd'");
$numrows = mysql_num_rows($query);
echo("$numrows");
}
else
echo("Bitte geben sie ihre Daten ein.");
?>
Posts: 31
Threads: 1
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: Sep 2011
Reputation:
0
Go fisrt to login.php, then press submit and watch if in login2.php you have the same error.
Go fisrt to login.php, then press submit and watch if in login2.php you have the same error.
Okay working now ... thanks for your help. :3
Posts: 768
Threads: 40
Thanks Received:
0 in 0 posts
Thanks Given: 0
Joined: May 2011
Reputation:
0
If u start to learn, and u are not familliar with a certain system yet.
Please start with mysqli or PDO, the old mysql_ functions used in php should no longer be used so it would be a waste to learn how to work with that.