How get the result from mysql select

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Robin_Hoo
Forum Newbie
Posts: 2
Joined: Wed Jan 08, 2003 1:16 am

How get the result from mysql select

Post by Robin_Hoo »

Hi, All,

I'm a beginner of PHP. I wanna use the aes_encrypt or aes_decrypt from mysql. But I don't know how to get the result of select aes_encrypt("text","password") from mysql. Is there anyone know how to handle it. Thanks.
User avatar
DaZZleD
Forum Commoner
Posts: 38
Joined: Tue Jan 07, 2003 5:39 am

Post by DaZZleD »

for some odd reason(i think) i cannot use the aes_encrypt() or aes_decrypt() function in mysql console mode ... but if this works for you, then this should work too:

Code: Select all

<?php

$link = mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect");
mysql_select_db("your database") or die("Could not select database");

$query="select aes_encrypt('text', 'password');";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$encrypted_text = $row[0];

?>
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Did you check here?

http://www.mysql.com/doc/en/Miscellaneo ... tions.html

Also note the versions of MySQL you need to use these functions.

Cheers,
BDKR
Robin_Hoo
Forum Newbie
Posts: 2
Joined: Wed Jan 08, 2003 1:16 am

Post by Robin_Hoo »

Thanks. DaZZleD and BDKR. That's very helpful advice. :)
Post Reply