rocafreestyler Posted September 23, 2007 Share Posted September 23, 2007 Hi I am very new to PHP as I usually use Coldfusion for all server side stuff, but constraints in a recent project have led us to using PHP as it is far more flexible when it comes to encryption. Let me start by giving a breif overview of what I am doing, I have a Flash application that uses AMFPHP (a Flash Remoting gateway for PHP). So for this I have a PHP script sitting on the server that deals with all calls to the server, the PHP script does it stuff and returns data to the Flash Application. This is all working fine I can call a function in the PHP script and return a result. The problem occurs when I call a function in the PHP script which then calls another function in the same class which is meant to return a value to the original function which then returns the result to Flash So in the example below I call the "autoUpdateEmail" function from Flash which makes its mySQL query, I was then hoping to call the "doEncryption" which would return an Encrypted value back to the "autoUpdateEmail" function which then returns the encrypted value back to Flash. If I skip the encryption function and just return the query result back to Flash it works fine. Both the function work on their own, just not together. I cannot for the life of me get it to call the "doEncryption" function, I really cannot see why this won't work. <?php class FlashFunctions{ function FlashFunctions(){ $this->methodTable = array( "doEncryption" => array( "description" => "Do Encrypt", "access" => "remote" ), "autoUpdateEmail" => array( "description" => "autoUpdateEmail", "access" => "remote" ) ); } // ENCRYPTION FUNCTION function doEncryption($decryptedString){ // if (!extension_loaded('mcrypt')){ return "NO EXTENSION INSTALLED"; }else{ // $key = "********"; // Convert the ASCII to Unicode by insert some 0 bytes for ($i = 0 ; $i < strlen($decryptedString) ; $i++){ $strUnicode .= $decryptedString[$i] . chr(0); } $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, ''); $iv = str_repeat(chr(0), ; mcrypt_generic_init($td, $key, $iv); $encrypted_data = mcrypt_generic($td, $strUnicode); mcrypt_generic_deinit($td); mcrypt_module_close($td); // return strtoupper(bin2hex($encrypted_data)); } } //AUTO UPDATE EMAIL function autoUpdateEmail($UserID){ $username = "********"; $password = "*******"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("CRM",$dbh) or die("Could not select first_test"); $result = mysql_query("SELECT * FROM tblUser WHERE userID = '$UserID'"); while ($row = mysql_fetch_assoc($result)) { $email = $row['Email']; } mysql_close($dbh); $returnStr = $email; // return(doEncryption($returnStr)); } } ?> Any help would be greatly appeciated. Regards Quote Link to comment https://forums.phpfreaks.com/topic/70371-solved-call-a-function-inside-a-class-and-returning-the-result/ Share on other sites More sharing options...
rarebit Posted September 23, 2007 Share Posted September 23, 2007 return($this->doEncryption($returnStr)); Quote Link to comment https://forums.phpfreaks.com/topic/70371-solved-call-a-function-inside-a-class-and-returning-the-result/#findComment-353532 Share on other sites More sharing options...
rocafreestyler Posted September 23, 2007 Author Share Posted September 23, 2007 Brilliant - i will give it a go first thing tomorrow Thank you Quote Link to comment https://forums.phpfreaks.com/topic/70371-solved-call-a-function-inside-a-class-and-returning-the-result/#findComment-353596 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.