WilliamNova Posted August 13, 2013 Share Posted August 13, 2013 I know undefined variables are simple to fix, but I can't seem to get this fixed at all. <?php include ("./inc/headerinc.php"); mysql_connect("localhost","root",""); mysql_select_db("mid"); $email = $_GET['email']; $check_email = mysql_query("SELECT * FROM users WHERE email='$email'"); $count = mysql_num_rows($check_email); if ($count == 1) { while ($row = mysql_fetch_assoc($check_email)) { $id = $row['id']; $firstname = $row['firstname']; $lastname = $row['lastname']; $email = $row['email']; $password = $row['password']; echo "<h2>$firstname's Profile</h2><br /> Name: $firstname $lastname<br /> Email: $email "; } } ?> In line 7 'email' is undefined. When I try using isset($_GET ['email']) the error goes away, but none of the information that's suppose to echo is displayed. Link to comment https://forums.phpfreaks.com/topic/281142-undefined-variable-help/ Share on other sites More sharing options...
PaulRyan Posted August 13, 2013 Share Posted August 13, 2013 $email = isset($_GET['email']) ? $_GET['email'] : FALSE ; Then add in a check to make sure $email is not false. if(empty($email)) { // The variable $_GET['email'] doesn't exist. } else { // Other code. } You also need to escape the variable before you use it in a query, to make sure it is safe to use. Link to comment https://forums.phpfreaks.com/topic/281142-undefined-variable-help/#findComment-1444909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.