cluce Posted June 11, 2007 Share Posted June 11, 2007 Can someone tell me if I have any errors in this code? For some reason it goes to the error page everytime, even though it has a value of 0 in the column confirmkey. I am able to update the field 0 or 1 for confirmkey at the approriate places in my code but this if condition is not working like it should. If confirm key is 0 its supposed to execute the rest of the code and if its a 1 its supposed to go to the error page. can someone tell me if I did this query right? //gets query for confirm key $checkemail = trim(strip_tags($_POST['email'])); $sql0 = "SELECT Confirmkey FROM auth_users WHERE email = '$checkemail' LIMIT 1"; $key = mysqli_query($mysqli, $sql0); if ($key == 1) { header("Location: ../error.html"); exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/55104-solved-not-sure-if-query-is-getting-correct-value-from-database/ Share on other sites More sharing options...
paul2463 Posted June 11, 2007 Share Posted June 11, 2007 not sure about mysqli at all but can you put in the "or die" phrase just like mysql such as //gets query for confirm key $checkemail = trim(strip_tags($_POST['email'])); $sql0 = "SELECT Confirmkey FROM auth_users WHERE email = '$checkemail' LIMIT 1"; $key = mysqli_query($mysqli, $sql0) or die ("error in query" . mysqli_error()); //this bit to see if there is an error thrown?? if ($key == 1) { header("Location: ../error.html"); exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/55104-solved-not-sure-if-query-is-getting-correct-value-from-database/#findComment-272399 Share on other sites More sharing options...
akitchin Posted June 11, 2007 Share Posted June 11, 2007 the return from mysqli_query() is a RESOURCE. you must then parse this resource with an extraction function to obtain the actual resultset returned by the query that you've run. think of mysql_query() as telling you where in a file cabinet to look for a document; you must then use something like mysql_result() or mysql_fetch_array() or a similar extraction function to actually grab the document from that file cabinet. Quote Link to comment https://forums.phpfreaks.com/topic/55104-solved-not-sure-if-query-is-getting-correct-value-from-database/#findComment-272406 Share on other sites More sharing options...
cluce Posted June 11, 2007 Author Share Posted June 11, 2007 thanks for the replies and sharing your knowledge I got it to work. Quote Link to comment https://forums.phpfreaks.com/topic/55104-solved-not-sure-if-query-is-getting-correct-value-from-database/#findComment-272447 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.