Jump to content

JasonHarper

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by JasonHarper

  1. That did the trick! Thanks a million!!
  2. Hello! I'm using mcrypt to encrypt/decrypt a string. In order to store the encrypted string in MySQL, I was using base64 to encode before storage, and base64 to decode after retrieving from storage and before decryption. I have something slightly wrong because my output of the decrypted string does contain the original string, but it also contains several ASCII characters behind it. Here is a code snippet (I eliminated all of the DB insert/select code to try and isolate the issue): //VARIABLE $string = 'password'; //ALGORITHM $alg = MCRYPT_RIJNDAEL_256; //INITIALIZATION VECTOR $iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, MCRYPT_MODE_ECB), MCRYPT_RAND); $key = 'Gjsj176502j1g71u72h171'; $encryptedString = mcrypt_encrypt($alg, $key, $string, MCRYPT_MODE_CBC, $iv); $encodedString = base64_encode($encryptedString); $decodedString = base64_decode($encodedString); $decryptedString = mcrypt_decrypt($alg, $key, $decodedString, MCRYPT_MODE_CBC, $iv); echo 'String: '.$string.'<p>'; echo 'Key: '.$key.'<p>'; echo 'Encrypted String: '.$encryptedString.'<p>'; echo 'Encoded String: '.$encodedString.'<p>'; echo 'Decoded String: '.$decodedString.'<p>'; echo 'Decrypted String: '.$decryptedString.'<p>'; Here is what I'm getting as a result of this code: String: password Key: Gjsj176502j1g71u72h171 Encrypted String: B��`P�fÚa�;U-ҳ�+KM�&��Κ�+ Encoded String: QpaxYFDis2bDmmHYOw9VLdKzlytLTeQmiAi5GM6a9Ss= Decoded String: B��`P�fÚa�;U-ҳ�+KM�&��Κ�+ Decrypted String: password������������������������ It looks like everything is fine until we get to the decrypted string - it contains the correct value but also all the ASCII. Any ideas what I'm doing wrong? Thank you!! Jason
  3. Hello, I need help with what I think is an easy issue. I have a list of all states in a MySQL database. I have a form where the user selects a state from a drop down list and I have that populated with info from the DB. That part is working perfectly. However, when the user returns to that page I'm pre-populating the form with their data. What's happening is that the user's state appears correctly in the pre-filled drop down list, but it appears at the top and then again in the list from the DB. Example: If user's state is Arizona, the drop down list would look something like this: Arizona Alabama Alaska Arizona ... My question is this....how do I make the user's state appear only once in the list and in the correct location (alphabetical order)? Thank you! Jason
  4. Thanks for the help! I'm having trouble even getting it as a variable: $snippet = " <!--SNIPPET//--> <script type="text/javascript"> var DID=12345; var pcheck=(window.location.protocol == "https:") ? "https://sniff.somehost.com/live.js":"http://stats.somehost.com/live.js"; document.writeln('<scr'+'ipt src="'+pcheck+'" type="text\/javascript"><\/scr'+'ipt>'); </script> <!--SNIPPET//-->"; So if I do stripslahses(mysql_real_escape_string($snippet)), my PHP page errors out. If I comment out the variable, there are no errors. Am I doing something wrong in the assignment of the variable $snippet ? Thank you! Jason
  5. Hello and Happy New Year! I'm having a bit of an issue with a string that has special characters. Essentially, I have a variable on each of my pages that pulls a code snippet from a database for my visitor tracking. However, I'm having trouble getting that string into the database because of all the special characters. Can anyone help me with the proper method/syntax to get this into my DB: <!--SNIPPET//--> <script type="text/javascript"> var DID=12345; var pcheck=(window.location.protocol == "https:") ? "https://sniff.somehost.com/live.js":"http://stats.somehost.com/live.js"; document.writeln('<scr'+'ipt src="'+pcheck+'" type="text\/javascript"><\/scr'+'ipt>'); </script> <!--SNIPPET//--> Thank you! Jason
  6. Hello! I'm having a massive brain block and can't figure something out. I have three dynamic content areas on my site (each with its own title, image, text, etc that is pulled from the DB). I want to randomly pull three records from the DB and populate the three sets of variables accordingly but just can't seem to get it to work. I know the code below is wrong but hopefully it will help to illustrate what I'm trying to do. Thank you for the help!! //QUERY DB FOR THREE BOX CONTENT $result = mysql_query("SELECT * FROM content_index_boxes ORDER BY RAND() LIMIT 3"); while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { $title1 = $record['title']; $subtitle1 = $record['subtitle']; $text1 = $record['text']; $image1 = $record['image']; $imagealt1 = $record['imagealt']; $linktext1 = $record['linktext']; $linkurl1 = $record['linkurl']; $title2 = $record['title']; $subtitle2 = $record['subtitle']; $text2 = $record['text']; $image2 = $record['image']; $imagealt2 = $record['imagealt']; $linktext2 = $record['linktext']; $linkurl2 = $record['linkurl']; $title3 = $record['title']; $subtitle3 = $record['subtitle']; $text3 = $record['text']; $image3 = $record['image']; $imagealt3 = $record['imagealt']; $linktext3 = $record['linktext']; $linkurl3 = $record['linkurl']; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.