HELP: Undefined variable

Reply

Join Date: Dec 2008
Posts: 1
Reputation: mattbaker is an unknown quantity at this point 
Solved Threads: 0
mattbaker mattbaker is offline Offline
Newbie Poster

HELP: Undefined variable

 
0
  #1
Dec 31st, 2008
Help!
I keep getting the following error:

<b>Notice</b>: Underfined variable: theHash in <b>C:\wamp\www\HelloSeanThisIsForYourMyFriend.php</b>on line<b>46</b><br/>
f5bd6294083c680ec4a0e05bf1dbce38


From file:
  1. <?php
  2. /*--------------------------------------------------------------------------------------
  3. -
  4. -
  5.  -
  6.   -
  7.  -
  8.   -
  9.   -
  10.   -
  11. -
  12. -
  13. -
  14.  -
  15.  -
  16.  -
  17. -
  18. -
  19. --
  20. -
  21. //
  22. $theMD5 = md5("ayht" . $_POST["rn"] . "thy", 1);
  23.  
  24. $hexArr[0] = "0";
  25. $hexArr[1] = "1";
  26. $hexArr[2] = "2";
  27. $hexArr[3] = "3";
  28. $hexArr[4] = "4";
  29. $hexArr[5] = "5";
  30. $hexArr[6] = "6";
  31. $hexArr[7] = "7";
  32. $hexArr[8] = "8";
  33. $hexArr[9] = "9";
  34. $hexArr[10] = "A";
  35. $hexArr[11] = "B";
  36. $hexArr[12] = "C";
  37. $hexArr[13] = "D";
  38. $hexArr[14] = "E";
  39. $hexArr[15] = "F";
  40.  
  41. for($i=0;$i<strlen($theMD5);$i++)
  42. {
  43. $tmp1 = ord($theMD5[$i]) / 16;
  44. $tmp2 = ord($theMD5[$i]) % 16;
  45.  
  46. $theHash = $theHash. $hexArr[$tmp1] . $hexArr[$tmp2];
  47. }
  48.  
  49. $theHash = strtolower($theHash);
  50.  
  51. echo $theHash;
  52. ?>
  53.  


Is there a simple fix to this please?
Last edited by mattbaker; Dec 31st, 2008 at 9:46 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: HELP: Undefined variable

 
0
  #2
Dec 31st, 2008
Set $theHash equal to empy before the for loop.
Also, I think you'll want to poulate $theHash like this:
  1. $theHash="";
  2. for($i=0;$i<strlen($theMD5);$i++)
  3. {
  4. $tmp1 = ord($theMD5[$i]) / 16;
  5. $tmp2 = ord($theMD5[$i]) % 16;
  6.  
  7. $theHash.= $hexArr[$tmp1] . $hexArr[$tmp2];
  8. }
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC