Jump to content

1 Line of Code: Printing results of query but from encrypted AES


phpretarded

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.