dlouis95 Posted May 30, 2010 Share Posted May 30, 2010 In the script provided, at if($email==$email2), it says it is false when I know it's true. I know that the cookie is the same as the email in the database, yet it sill wont work. I have even echoed the two to see myself if they were the same, and they were, yet it still is saying it's false. Anyone know whats up? Thanks! if(isset($_COOKIE['dan'])) { $email=$_COOKIE['dan']; $host = ...; $username = ...; $password = ...; $db_name = ...; $tbl_name = ...; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $user=$_GET['username']; if(mysql_num_rows(mysql_query("SELECT username FROM $tbl_name WHERE username = '$user'"))) { $sql="SELECT * FROM $tbl_name WHERE username='$user'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); $email2=$rows['email']; if($email == $email2) { ?><html>...</html><? } else { ... Link to comment https://forums.phpfreaks.com/topic/203323-why-wont-this-work/ Share on other sites More sharing options...
Pikachu2000 Posted May 30, 2010 Share Posted May 30, 2010 What is this supposed to do? It's only part of a conditional . . . ---> if(mysql_num_rows(mysql_query("SELECT username FROM $tbl_name WHERE username = '$user'"))) Link to comment https://forums.phpfreaks.com/topic/203323-why-wont-this-work/#findComment-1065222 Share on other sites More sharing options...
dlouis95 Posted May 30, 2010 Author Share Posted May 30, 2010 What is this supposed to do? It's only part of a conditional . . . ---> if(mysql_num_rows(mysql_query("SELECT username FROM $tbl_name WHERE username = '$user'"))) That's to check if a record exists. I googled a way to do this, this is what it gave me, and it works. Link to comment https://forums.phpfreaks.com/topic/203323-why-wont-this-work/#findComment-1065223 Share on other sites More sharing options...
kenrbnsn Posted May 30, 2010 Share Posted May 30, 2010 Check the string length of each item. Maybe there's a space before/after one of the values. BTW, you really shouldn't use any value gotten from the URL without sanitizing it. <?php $user=mysql_real_escape_string($_GET['username']); ?> Ken Link to comment https://forums.phpfreaks.com/topic/203323-why-wont-this-work/#findComment-1065224 Share on other sites More sharing options...
dlouis95 Posted May 30, 2010 Author Share Posted May 30, 2010 Check the string length of each item. Maybe there's a space before/after one of the values. BTW, you really shouldn't use any value gotten from the URL without sanitizing it. <?php $user=mysql_real_escape_string($_GET['username']); ?> Ken Thanks man! Turns out my problem was nothing(space before $email)! Thanks for telling me to sanitize the url value. I haven't gotten to that yet, but have done it for forum entry's. Link to comment https://forums.phpfreaks.com/topic/203323-why-wont-this-work/#findComment-1065227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.