php

PHP: How to calculate person age in months.

I have searched for this but did not find a perfect function in php. I want to get a php function that calculate person age only in months. For example: less then one month old. 5 months old. 340 months old. Thanks ...

CodeIgniter Controller problem

Hello, This is my AdminBase.php <?php class AdminBase extends Controller{ public function __construct(){ parent::Controller(); $admin = $this->session->userdata('username'); if(!isset ($admin)){ redirect('/Site/Home'); } } } And this is my Admin Controller :- <?php class Admin ...

File_get_contents not working?

Hi, I am using cakephp. I am trying get data from facebook using file_get_contents. I get a warning. Warning (2): file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration Warning (2): file_get_contents(https://graph.facebook.com/XXXXXXX/?access_token=111978178XXXXXX|2.lg65A3c...

Is there a PHP equivalent of Rails migrations?

Is there a PHP equivalent of Rails migrations? Looking for a good solution for configuring schema changes locally and then automatically bumping them to the server without losing data. ...

Runtime Revolution simple but hard question...

Can anyone convert this RunRev function to a usable PHP function? I'm not an expert when it comes to PHP so I hope somebody helps me... Here is the RunRev code snippet, -> http://paste-it.net/public/n8a6437/ I hope somebody helps me... ...

Get the source of a file using php

Hey everybody, I'm trying to get the source of a file using php and the file_get_contents function. The problem is that the website requires a login. I thought that this could be bypassed by logging into the site first and then use the file_get_contents function but this is not the case. The page that the function returns is the login p...

Getting data from nested array passed to Javascript / Jquery from PHP / Cakephp via JSON

Sorry for asking a basic question like this but I've been reading on this for a few hours now and the examples aren't making sense to me in context of the way my array is.. I have been able to pass this from my server side (cakephp) to the javascript (I'm using jquery) but after that, I am lost as to how to make use of the data.. I tried...

advice about ASP.NET and PHP for building an auction web site

Hello, I need expert advises about building an auction web site in general and I dont need code help. I stopped one year for developing web sites and I need to know which is more suitable and easy to extend to build this web site If I used ASP.NET which ORM I should use or I dont have to use it ? and should I use expression web as the...

Trying to use regex matches between words using PHP

Hello, I am trying to match HTML tags that might occur between words on a web page, using regex's. For example, if the sentence that I want to match is "This is a word", I need to develop a pattern that will match something like "This is a <b>word</b>". I've tried using the code below to prepare the regex pattern: $pattern = "/".str_...

How do I make an HTML button’s onclick event trigger one of two different functions at random?

How do I make an HTML button’s onclick event trigger one of two different functions at random? I’m using PHP on the server, and jQuery on the client. Using this code when i click the button image nothing happens... function a(){ alert('A got called!'); } function b(){ alert('B got called!'); } $('#button').bind('click...

Serving JSON and HTML securely to JavaScript

Hi, I am thinking of secure ways to serve HTML and JSON to JavaScript. Currently I am just outputting the JSON like: ajax.php?type=article&id=15 { "name": "something", "content": "some content" } but I do realize this is a security risk -- because the articles are created by users. So, someone could insert script tags (just ...

Add data dynamically to an Array

I want to add data to an array dynamically. ...

Run normal SQL using Doctrine 2

i know i can run DQL and all the fancy ORM features using Doctrine. but for development, maybe i want to just initialize the database with defalt data. say i want to do: truncate the database tables initialize tables with default test data i am thinking it will be good if i can just go to a page say /initData that truncates databas...

SMTP problem with PHP form in Godaddy hosting!

I was testing this (nice) simple form from CSS Tricks. In a website hosted in Godaddy. And I got the following warning: Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html in D:\Hosting\4923367\html\test\contactengine on line 32. (I checked the page but i didn't see anyth...

Integrating ZF/Doctrine2: Where do i put my Models/Entities & Proxy classes

if i do integrate Zend Framework 1.10 with Doctrine 2 where do i put my Doctrine Models/Entities and Proxies? i thought of the /application or the /library directories. if i do put in the /library directory tho, will it interfere with ZF autoloading classes from there since the classes there will be using PHP 5.3 namespaces vs PEAR style...

Get most active users by the amount of comments

I want to display most active users by the amount of comments they have left on my site. I can't figure out what would the mysql query look like for this. There is no table that holds the total amount of comments for each user. I need to count the total amount of comments for each user somehow and display for example top 10 users with mo...

How can i use HTML5 local storage along side PHP, use that for php sessions, and store other information that php uses.

I have been looking on the web for some time now and HTML5 local storage seems to look like something useful to me and a solution to my problem that I am having with PHP sessions, the problem is that they are not consistent even if I set them to remember me the next time I come to my home page I am taken to the login page, this is not al...

how to crop image in codeigniter ?

Hello i'm using codeigniter to build a project and right now i need to create a thumb depending on user choice. like he will give me X1,Y1,X2,Y2,X3,Y3,X4,Y4 i want to crop the image depending on that 4 points. i checked the image manipulation class. the crop function seems to be very strange. any help please ? ...

Hiding and showing parts of an html with PHP?

The example I have in HTML: <div id="red-nav-warp"> <ul id="red-nav-logo"> <li><img class="sponsors" id="sponsorone" src="media/img/logosmall.png" /></li> </ul> <ul class="clearfix" id="red-nav-list-member" > <li><?php $themeSys->Href('logout',$langSys->get('LOGOUT')); ?></li> <li><?php $themeSys->Href('settings',$lang...

Error using IMAP in PHP?

I was using the code, <?php $mbox = imap_open("https://myserver.in", "[email protected]", "123456", OP_HALFOPEN) or die("can't connect: " . imap_last_error()); $list = imap_getmailboxes($mbox, "https://myserver.in", "*"); if (is_array($list)) { foreach ($list as $key => $val) { echo "($key) "; echo imap_utf7_decode($va...