php

Calculating script memory usages in PHP?

Is it as simple as calling memory_get_usage() at the start and end of a script and subtracting the 1st from the second value, to get the total memory used on that script? If so, how can I convert that value to a more understandable number like kb and mb? ...

Which symmetric encryption algorithm is the fastest for smaller messages?

I am interested in help selecting one of the common symmetric encryption algorithms (Twofish, AES, etc) based on performance criteria (fastest encryption/decryption). We are currently leaning toward AES, but since the communications we are sending back and forth don't really need that level of encryption, a less secure algorithm would b...

preg_match how should i use

Hello, I have a string to check and if it is only numbers and digits perform another action else exit; $data = 123412347JB91742F; if(preg_match('/[A-Z1-9]/', $data )) { echo $data; } else { exit; } this works fine but if i add anything to $data like $ or any other thing it still prints the value what is wrong with code? //...

Fatal error: Cannot instantiate non-existent class: simplexmlelement

I'm using this php script $error = false; if(isset($_POST['login'])){ $username = preg_replace('/[^A-Za-z]/', '', $_POST['username']); $password = md5($_POST['password']); if(file_exists('users/' .$username . '.xml')){ $xml = new SimpleXMLElement('users/' .$username . '.xml', 0, true); if($password == $xml->passwor...

Facebook app - allow user to upload image

Hi I want to create a page in my facebook app which lets user upload an image from their system. How can I do this? The image will be stored on my server and not in the user's photos. Thanks. ...

Facebook - show a help dialog

Hi How can I show a typical facebook modal help dialog when the user clicks on one of the links on my Facebook app? Thanks. ...

Implementing file upload progress with Zend

Hi Im attempting to implement upload progress with Zend however I havent found any detailed tutorials. A pointer would be useful. Thanks. ...

Problem with heredoc statement

I am trying to replace the HTML code with a heredoc statement. However, I am getting a parse error in the last line.I am sure that I have not left any leading space or indentation on the heredoc closing tag line.Following is a part of the code: $table = <<<ENDHTML <div style="text-align:center;"> <table border="0.5" cellpadding=...

use php date string in javascript

i have a date entry in yyyy-mm-dd format in mysql database. Using php i could get the date value $row = $myresult['date']; now i wish to alert this value in javascript so i tried var temp_date = <?php echo($row)?>; alert (temp_date); but that didn't work for me. The problem i feel i am facing is to maintain the string format of th...

php warning - headers already sent after server move

I’m moving the website to a new server and I’m now getting this error! Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/com10002/public_html/bank/index.php:29) in /home/com10002/public_html/bank/includes/quickform.php on line 5 I have put session_st...

Need a regex that will check if the string only consist letters a-z and numbers and underscore(_) and hyphen(-)

I'm looking for a regex that will check if the string only consists of the letters a-z, numbers, underscore (_) and hyphen (-). I have tried this, but it does not work: if (!preg_match('/^a-zA-Z0-9_-$/', $string)) { $reg_Error[] = 2; } Also, can I check the length with regex? If not, I will just do it with PHP. ...

Adobe AIR with PHP/MySql or sqllite

What would be a better choice for making a database driven Adobe AIR(Desktop) application? Using PHP+MySql with AIR OR Using SQLite If I choose SQLite, then I cannot reuse my code for an online application. If I choose 1, I have to block few port numbers on User's machine. Also, I am using XAMPP for providing the user with PHP a...

PHP: flatten multidimensional array

I need to explode by "," then ":". Easy enough... $alttitle = "35:title1,36:title2, 59:title5" $replacetitles = explode(",",$alttitle); for ($i = 0 ; $i < count($replacetitles) ; $i++) { $replacetitle[] = explode(":", $replacetitles[$i]); } Which produces... Array ( [0] => Array ( [0] => 35 [1] => title1 ) [1] => Array ( [0] => 36...

Sending attachments using mail() - not attaching

Hey, I have been working with: http://www.sitepoint.com/article/advanced-email-php/6/ along with other articles on trying to get my email to be sent with an attachment and as of now: It sends the email, with the plain text content, it looks like: http://pastie.org/569806 My code as of now is: http://pastie.org/569803 - I didnt want to...

Pseudo-code for shelf-stacking

Suppose I have some serially numbered items that are 1-n units wide, that need to be displayed in rows. Each row is m units wide. I need some pseudo-code that will output the rows, for me, so that the m-width limit is kept. This is not a knapsack problem, as the items must remain in serial number order - empty spaces at the end of rows a...

Best ways to handle Record Form in Zend Framework

Once you're OK with basic record form built after example from Tutorial, you realize you want more professionally designed Record Form. E.g. I don't want to duplicate record form for the same table in User and Admin areas. 1) Does anyone use some mechanism, possibly inheritance, to reduce duplication of almost similar admin and user for...

What do I call in PHP to check if a string matches a pattern?

I'm a noob. I found [this URL shortener code][1] on the web. Pretty simple and straightforward and this noob was able to install, configure and get it up and running with little issue! Now I want to add something. I want to throw an error to user if they enter a link from bit.ly, TinyURL.com or tr.im. I want it to say, "Sorry, we ...

Anyone else using DB-Schema-Validation for MVC projects?

Ok, inspired in part by CakePHP's Model Validation I created a project which uses a separate database schema file. I didn't like that in CakePHP the model file and the db-schema are combined in the same php file. I like having them separate. All of my sql updates, inserts, and deletes are first passed by this schema. I wrote update() in...

Ruby/Rails eqv PHP get_meta_tags

Is there an equivalent ruby/RoR method for PHP get_meta_tags. I am looking to read the meta tag information of a given url ...

Ideas for Software Engineering Thesis Project

Hey everyone, I am in a Software Engineering Master's program, and I have to start my thesis work pretty soon. I understand that ultimately, the decision on what I do has to be up to me, but I was hoping to try and get a couple ideas. My advisor was right in telling me that the hardest part is coming up with a good idea. The requiremen...