AES_DECRYPT Will Not Output the Information

Discussion in 'PHP' started by ZW Neo, Jun 3, 2010.

  1. #1
    Hello, I've been trying to debug this script of mine, and I finally got AES_DECRYPT to work after using the SQL database for a little help in putting together the mysql_query. Those little buggers are always so confusing.
    Anyways, I finally got it to work, and in the actual SQL query, it produced the correct information. When I converted it to PHP and tried out the script, however, I got this:
    Resource ID#5

    I'm absolutely baffled.
    Here's the code:
    mysql_connect("localhost","root");
    mysql_select_db("edit_db");
    $art=$_POST['title'];
    $result=mysql_query("SELECT * FROM articles");
    $row=mysql_fetch_array($result);
    $sql = mysql_query("SELECT aes_decrypt(`Text`, \"lolsecret\") FROM articles WHERE `Title` = \"$art\"");
    if ($row['Title'] == $art)
    	{
    	echo "$row[Title]<hr><br/>".$sql."<br/><a href='view.php'>Return to viewing</a> <a href='edit.php'>Edit this page</a>";
    	}
    else
    	{
    	echo "No matches found.";
    	header("refresh:4;http://localhost/Tests/edit/view.php");
    	}
    PHP:
    I tested it by making an "article" named "Day" with the content "A day is a thing." What this thing output was:

    Day<hr/><br/>
    Resource id #5<hr/><br/>
    (Return to viewing) (Edit this page)

    I was wondering why it was doing this when it correctly displayed the information while I ran the query in the database. If anyone can help me out, I'd greatly appreciate it!
     
    ZW Neo, Jun 3, 2010 IP
  2. wigwambam

    wigwambam Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not sure but you may need to use alias in SELECT:

    $sql = mysql_query("SELECT aes_decrypt(`Text`, \"lolsecret\") AS mytext FROM articles WHERE `Title` = \"$art\"");
     
    wigwambam, Jun 3, 2010 IP
  3. ZW Neo

    ZW Neo Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nope, that didn't help.
     
    ZW Neo, Jun 3, 2010 IP