469,142 Members | 1,117 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,142 developers. It's quick & easy.

How to redirect

3
Will you tell what I'm doing wrong. It goes straight to "expiredpage.html" even though the value
of "expiry" is more than 0. I keep studying redirection and variable definition but nothing works. It does
update.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $link = mysqli_connect("localhost", "root", "", "prerentdb"); 
  3. // Check connection
  4. if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }
  5.  
  6. $id='id';
  7. $expiry='expiry';
  8.  
  9. $sql = "UPDATE numbers SET expiry=$expiry- 1 where id=$id";
  10. if(mysqli_query($link, $sql)){ echo "expiry was updated successfully."; } 
  11. else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); }
  12.  
  13. if ($expiry == 0) { 
  14. header("location:expiredpage.html");
  15. // window.location.href = 'expiredpage.html';
  16. // $(location).attr('href', 'expiredpage.html')
  17.  } 
  18.  
  19. else  { 
  20.  header("location:sysnav.html");
  21. //window.location.href = 'sysnav.html';
  22. //  $(location).attr('href', 'sysnav.html')
  23.  } 
  24. // Close connection
  25. mysqli_close($link);
  26. ?>
Aug 11 '21 #1
1 1677
dev7060
489 Expert 256MB
bytM3
Will you tell what I'm doing wrong. It goes straight to "expiredpage.html" even though the value
of "expiry" is more than 0. I keep studying redirection and variable definition but nothing works. It does
update.
Src https://wiki.php.net/rfc/string_to_n...n#introduction
Comparisons between strings and numbers using == and other non-strict comparison operators currently work by casting the string to a number, and subsequently performing a comparison on integers or floats. This results in many surprising comparison results, the most notable of which is that 0 == "foobar" returns true. This RFC proposes to make non-strict comparisons more useful and less error prone, by using a number comparison only if the string is actually numeric. Otherwise the number is converted into a string, and a string comparison is performed.
4 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Bob Garbados | last post: by
3 posts views Thread by Paul | last post: by
7 posts views Thread by Donna Hawkins | last post: by
1 post views Thread by Peter Kirk | last post: by
2 posts views Thread by Mark Dengler | last post: by
3 posts views Thread by Justin | last post: by
6 posts views Thread by Peter Row | last post: by
10 posts views Thread by Eirik Eldorsen | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.