Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKonrad Pilch
2,435 PointsErrors, i dont quite get them.
What are these errors?
Warning: main(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:\MAMP\htdocs\001Social News Site\login.php on line 37
Notice: Undefined variable: connect in C:\MAMP\htdocs\001Social News Site\login.php on line 37
Warning: mysqli_query(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:\MAMP\htdocs\001Social News Site\login.php on line 37
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\MAMP\htdocs\001Social News Site\login.php on line 37
Warning: main(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:\MAMP\htdocs\001Social News Site\login.php on line 38
Notice: Undefined variable: connect in C:\MAMP\htdocs\001Social News Site\login.php on line 38
Warning: mysqli_affected_rows(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:\MAMP\htdocs\001Social News Site\login.php on line 38
Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, null given in C:\MAMP\htdocs\001Social News Site\login.php on line 38 Incorrect username and password combination Go back
2 Answers
Kevin Korte
28,149 PointsWhat does your database file look like?
Kevin Korte
28,149 PointsWhat does your code look like on lines 37 and 38?
Konrad Pilch
2,435 Points//34// include ('libraries/database.php');
//35
//36 $query = ("SELECT * FROM users WHERE user_username ='$username'");
//37 $result = mysqli_query($connect, $query);
//38 $hits = mysqli_affected_rows($connect);
//39
//40 if($hits < 1){
//41
//42 echo "Incorrect username and password combination";
//43 die("<br /><a href='index.php'>Go back </a>");
//44
//45 }
Konrad Pilch
2,435 PointsNotice: Undefined variable: connect in C:\MAMP\htdocs\001Social News Site\login.php on line 37
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\MAMP\htdocs\001Social News Site\login.php on line 37
Notice: Undefined variable: connect in C:\MAMP\htdocs\001Social News Site\login.php on line 38
Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, null given in C:\MAMP\htdocs\001Social News Site\login.php on line 38 Incorrect username and password combination Go back
Konrad Pilch
2,435 PointsDatabase looks like this
table - users
and
user_id
user_email
user_password
user_firstname
user_lastname
user_avatar
user_shortbio
user_username
user_dob
user_gender
user_joindate
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsKonrad Pilch
2,435 Pointsohhhhhhhhhhh righttttt, i used variable connect instead of database :ppp let me change thath : pp
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 Pointsit works now, i also added this in the login file date_default_timezone_set('UTC');
and btw, what od you think about the code? with more practice and better security for use in production? its very simple but it doesnt have to be complex to use it right
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsIts working now , thank you!