phpretarded Posted June 3, 2012 Share Posted June 3, 2012 Hello I have to print the results of the query but since they were encrypted, I have to include that in the printing statement and I can't get to write it properly. echo "$row AES_DECRYPT(['FName'], 'salt'])"; Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/ Share on other sites More sharing options...
trq Posted June 3, 2012 Share Posted June 3, 2012 Your example and description don't help at all. Learn to prepare a decent question and come back. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1350827 Share on other sites More sharing options...
phpretarded Posted June 3, 2012 Author Share Posted June 3, 2012 This only means you dont understand anything, perhaps you should review the chapters about encryption. That is about printing a statement that has previously been encrypted using the AES_ENCRYPT(item,'salt') Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1350832 Share on other sites More sharing options...
gristoi Posted June 3, 2012 Share Posted June 3, 2012 phpretarded, i highy doubt thorpe needs to read up on encryption,seeing as he knows what he's talking about, but seeing as you want throw some insults around i would advise that YOU do some reading up on encryption as AES_DECRYPT and AES_ENCRYPT are both MYSQL functions and not PHP, so trying to meld them into a php statement is not going to work. you need to decrypt it in the sql statement. he forums here to help people with issues, not to insult one another. If you want to do that then by all means toddle of to facebook Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1350833 Share on other sites More sharing options...
ManiacDan Posted June 4, 2012 Share Posted June 4, 2012 mysqlretarded, PHP and MySQL are two separate languages and cannot be mixed and matched like this. You must form a full and proper MySQL command and dispatch it to the MySQL server every time you wish to do anything. Make a correctly formed MySQL statement first, review the manual chapters if necessary, then come back. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351115 Share on other sites More sharing options...
phpretarded Posted June 6, 2012 Author Share Posted June 6, 2012 Hello, I have the sql query selecting the values which were encrypted, and I do it like this "select AES_DECRYPT (country, 'salt') and it is fine, but when it comes to printing, looks like it has to also have all the aes_decrypt stuff, so this : <td><?php echo" {$query_row['country']}";?></td> will not work. It still needs the aes_decrypt and 'salt' stuff somewhere embedded in there. that is the question, how do you print out a result row that comes from a decrypted query Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351627 Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2012 Share Posted June 6, 2012 How is this different from the other thread you already have open on this subject? Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351628 Share on other sites More sharing options...
.josh Posted June 6, 2012 Share Posted June 6, 2012 phpretarded I would suggest in addition to reading up on how to properly use AES_DECRYPT within a mysql query, you should also read up on php syntax in general. Even if AES_DECRYPT was a php function, you still did it wrong. $row (I assume) is a variable you assigned from something like mysql_fetch_assoc or similar, which means it would be an array of data, for instance $row['FNname']. Well you can't just split up the array and its index like that. Also, function calls within (double) quotes don't work, only variables. The syntax would be more like echo AES_DECRYPT($row['FName'], 'salt']); but again, that's just "if it were..." scenario..again, and as others have mentioned, AES_DECRYPT is a mysql function, not a php function. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351631 Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2012 Share Posted June 6, 2012 Since you didn't actually post your query and your code, its not real clear what the problem is, but I'll guess you need to use an alias name in your query for the decrypted value so that you can reference the alias name when you fetch the row of data from the result set. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351634 Share on other sites More sharing options...
phpretarded Posted June 6, 2012 Author Share Posted June 6, 2012 In that I explain more what it is and hope to get an answer How is this different from the other thread you already have open on this subject? Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351664 Share on other sites More sharing options...
phpretarded Posted June 6, 2012 Author Share Posted June 6, 2012 I have it done in the sql query and I did it rightly with prepared statements, it is currently working on my website. Now I am implementing a similar thing but without prepared statements and the sql query goes like this: $query = mysql_query("SELECT AES_DECRYPT(country, 'elperrodesanroquenotienerabo'), FName from mytable"; FROM work_assignment, phpretarded I would suggest in addition to reading up on how to properly use AES_DECRYPT within a mysql query, you should also read up on php syntax in general. Even if AES_DECRYPT was a php function, you still did it wrong. $row (I assume) is a variable you assigned from something like mysql_fetch_assoc or similar, which means it would be an array of data, for instance $row['FNname']. Well you can't just split up the array and its index like that. Also, function calls within (double) quotes don't work, only variables. The syntax would be more like echo AES_DECRYPT($row['FName'], 'salt']); but again, that's just "if it were..." scenario..again, and as others have mentioned, AES_DECRYPT is a mysql function, not a php function. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351665 Share on other sites More sharing options...
ManiacDan Posted June 6, 2012 Share Posted June 6, 2012 This code you posted is not valid PHP and would throw parse errors. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351666 Share on other sites More sharing options...
Jessica Posted June 6, 2012 Share Posted June 6, 2012 As you were told before, you would do it in your query. What is the query to select it? Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351669 Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2012 Share Posted June 6, 2012 In that I explain more what it is and hope to get an answer How is this different from the other thread you already have open on this subject? Same problem; threads merged. Quote Link to comment https://forums.phpfreaks.com/topic/263585-1-line-of-code-printing-results-of-query-but-from-encrypted-aes/#findComment-1351692 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.