php

MIME/IMF error codes?

I need to write php code to identify common e-mail errors, like "inbox full" or specially "invalid email name" from email messages, because we need to clear our databases from nonexistent emails. I'm looking the MIME and IMF formats but I didn't find any kind of standard error code, does it exist? ...

(php) date and time

(php) how to get date and time into one string ($moment) and if it works, can mysql do this: SELECT * FROM table ORDER BY moment ASC ? ...

How to limit a users uploaded image size using PHP

I was wondering how would you limit an uploaded image size to 5mb using PHP & MySQL. ...

Call a constructor from variable arguments with PHP

Hello guys, I have a function that takes variadic arguments, that I obtain from func_get_args(). This function needs to call a constructor with those arguments. However, I don't know how to do it. With call_user_func, you can call functions with an array of arguments, but how would you call a constructor from it? I can't just pass the...

String to array or Array to string tips on formats, etc

hi, first of all thanks for taking your time! I'm a junior Dev, working with PHP + mysql. My issue: I'm saving data from a form to my database. From this form, there's only need to save the contacts: Name, phone number, address. But, it would be nice to have a small reference to the user answers. Let's say for each question we've go...

showing content in profile box from another file

i'm stuck at this facebook application, not knowing how do i go ahead. for the canvas, the app works quite perfectly. i've two pages, quote.html and quote.php. in quote.html, quote.php [which gets the quotes from the database] is called through ajax which displays a quote randomly for 10 secs. however, for the wall tab/profile box, i ...

Getting search results from Twitter in php

I'm attempting to put together a little mashup with some twitter APIs. However, the whole area is new to me (I'm more of an embedded developer dabbling). And frustratingly, every tutorial I am trying in Php is either out of date, not doing what it claims to do, it or is broken. Essentially, I just want a nice bit of example code - say...

Which PHP MVC project is most similar to ASP.NET MVC?

Title says it all. In regards to action heplers, routes, etc... I look forward to answers from people who've worked with both ASP.NET MVC and some PHP MVC project... ...

how to echo data that we read with file_get_contents

i want to check remote url's page contents. IF remote site's page content contains string http://yahoo.com set $qqq = YH if not contains $qqq = NOYH. i am not talking about "url of that page" im talking about page content of url $url = "'".$get['url']."'"; $needle = "http://yahoo.com/"; $contents = file_get_contents($url); if(stripos($c...

How do I get preg replace to work when the url contains a hashtag

I found a function online for turning a url within a string into a clickable link. However, when the url contains a hashtag it doesn't work. eg. http://www.bbc.co.uk/radio1/photos/fearnecotton/5759/1#gallery5759 Here's the part of the function concerned: $ret = preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a ...

Reuse, Rewrite, or Refactor?

At work I inherited development of a PHP-based Web site after the consultant who originally produced it bailed out and left without a trace. Literally half of the code is ripped from online tutorials, and there are thousands of lines of cruft that, being incomplete, do precious little. Hardly any of it actually works. I've been trying to...

Is it ok to call non static methods with call_user_func in PHP 5.3?

Hi folks! When I use call_user_func on a non-static method in PHP 5.2 I get a Strict Warning: Strict Standards: Non-static method User::register() cannot be called statically But on PHP 5.3.1 I don't get this warning. Is this a bug in PHP 5.3.1 or is the warning removed? ...

mysql_connect() causes page to not display (WAMP)

I currently have a website running MySQL and PHP in which this is all working. I've tried installing WAMPServer to be able to work on the site on my own computer, but I have been having issues trying to get the site to work correctly. HTML and PHP files work correctly (by going to http://localhost/index.php, etc.). But some of the p...

Get single Wordpress gallery image with given title

I am having users of a Wordpress blog upload a single image to different post's galleries with the name "banner". Basically, every post will have an image named "banner" uploaded to its gallery and this image needs to be displayed on the post's page outside of the article content. So, how can I get the URL to display an image in a post...

What is best way to pass multiple query parameters to a restful api?

I am designing RESTful Api's and would like some advice on designing an API where the caller wants to query records based on more than one search parameter. I have only seen restful apis that use one parameter. how should i do this? e.g. if i have created a restful api for a list of contacts, how would I format a call that returned al...

Security benefits from a second opinion, are there flaws in my plan to hash & salt user passwords via postgresql?

Here is my plan, and goals: Overall Goals: Security with a certain amount of simplicity & database-to-database transferrability, 'cause I'm no expert and could mess it up and I don't want to have to ask a lot of users to reset their passwords. Easy to wipe the passwords for publishing a "wiped" databased of test data. (e.g. I'd like t...

MySQL: 4 Table "has-many-through" Join?

Let's say I have the following 4 tables (for examples' sake): Owners, Trucks, Boxes, Apples. An owner can have many trucks, a truck can have many boxes and a box can have many apples. Owners have an id. Trucks have an id and owner_id. Boxes have an id and truck_id. Apples have an id and box_id. Let's say I want to get all the apple...

Magic Method __set() on a Instantiated Object

Ok i have a problem, sorry if i cant explaint it clear but the code speaks for its self. i have a class which generates objects from a given class name; Say we say the class is Modules: public function name($name) { $this->includeModule($name); try { $module = new ReflectionClass($name); $instance = $module->i...

CodeIgniter - the right way to create "block" elements on web page

Hello. I've been searching for a solutions for this problem a while but haven't seen any "valid mvc" solution for this. I hope I can explain my problem clearly enough for you guys. I need to create a dynamic block of HTML on my website. (eg. a block containing user's latest blog comments). I have a template view file (a file containing...

How can I add my desired links to be read using PHP Universal FeedParser

Hello, I have been trying to use the PHP Universal FeedParser to read RSS feeds and display the output on my site. Problem is I am VERY green with this and although it seems very simple. the only link that is working is the link provided in the sample. When I try to add another address with the xml or rss.php extensions, I keep getting e...