php

Call to drupal_render() returns NULL

I have been looking since yesterday but can't understand why a call to drupal_render() is returning NULL. In my node theme function, when I call drupal_render($element) with $element being defined like below, it renders nothing! <?php Array ( [#type] => textfield [#title] => Label [#default_value] => [#post] => Array ...

[php] memory_get_usage

I'm making a little benchmark class to display page load time and memory usage. Load time is already working, but when I display the memory usage, it doesn't change Example: $conns = array(); ob_start(); benchmark::start(); $conns[] = mysql_connect('localhost', 'root', ''); benchmark::stop(); ob_flush(); uses the same memory as $conn...

CakePHP - How can i define route to a non-cakephp file that doesnt have any controllers associated with it?

Im working in CakePHP now. I'd like to know how i can define a route to a non-cakephp file that doesnt have any controllers associated with it? I have placed this file(sitemap.php) in webroot folder, for my convenience. Now i need to route to it somehow! ...

Wordpress Multiple Developer Setup

Is there a good option for having more than one person developing a Wordpress application with a testing site. The biggest hurdle that I have encountered are path issues when developing locally and integrating to a testing environment. Does anyone have a good process for maintaining developer environment(s), keeping working content a...

Should we use Pylons or PHP for our webapp?

My friend and I are planning on building a sort of a forum type of webapp. We've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is ...

ODBC query on MS SQL Server returning first 255 characters only in PHP PDO (FreeTDS)

I'm currently trying to pull some data from a SQL Server database view that we have restricted access to from our Linux web server. We don't need to edit the data just display it in a webpage. It all looks fine until we try to output and only get the first 255 characters of a text field. Does anyone know if this is a problem with usin...

MySQLIi is not accepting my database login details

Below is my code that I am using. I know that the details are correct as they are identical to another page that connects to the database fine. However with this code I get the error: Access denied for user 'un'@'localhost' (using password: YES). Can anyone tell me what it is i'm doing wrong? Thanks $hostname = 'localhost'; $username =...

Which is the best and fastest way to compare two urls?

Hello, I have two tables with list of urls fetched from different sources. I want to find the common entries and put them in separate table. This is what I'm doing: find md5 hash of url while fetching them. Store them in a column. I fetch one table as an array, run a loop through it and insert the values from other table where md5...

How to include the post-count of a category to link-item when listing categories?

Hello! How could I include the count of posts under a category into the a-tag when listing categories. This has been a problem for me many times but now I decided to find out. <li><a href="#" title="asd">php</a> (1)</li> to <li><a href="#" title="asd">php (1)</a></li> Is you propably assumed, I'm using wp_list_categories to make t...

Simple XML Load File not working

Hi, how come this isn't working: $url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20xpath%3D%22%2F%2Fmeta%22%20and%20url%3D%22http://www.cnn.com%22&amp;format=xml&amp;diagnostics=false"; $xml = (simplexml_load_file($url)) I get multiple errors telling me the HTTP request failed. Ultimately I want to...

Best Way to handle Relational Data in CodeIgniter?

When creating a CodeIgniter project, what is the best way to handle relations between models? Should models contain other models that they are related to, should this be handled in the controller, or is there some other way to handle these scenarios? I'm thinking about one-to-one, one-to-many, or many-to-many relationships. example: let...

How to wrap Zend_Form error message in custom html?

Hi, I need to wrap zend form error messages in custom html. <div class="cerror" id="ID-error"> <div class="ui-widget"> <div class="ui-state-error ui-corner-all" id="IDerror-msg"> %ZEND_FORM_ERROR_MESSAGE% </div> </div> </div> Now I get errors in format: <ul> <li>Error message</li> </ul> I nee...

PHP json_decode() returns NULL with valid JSON?

I have this JSON object stored on a plain text file: { "MySQL": { "Server": "(server)", "Username": "(user)", "Password": "(pwd)", "DatabaseName": "(dbname)" }, "Ftp": { "Server": "(server)", "Username": "(user)", "Password": "(pwd)", "RootFolder": "(rf)" }...

failed to open stream: Invalid argument

In this code : $path = "C:\NucServ\www\vv\static\arrays\news.php"; $fp = fopen($path, "w"); if(fwrite($fp=fopen($path,"w"),$text)) { echo "ok"; } fclose($fp); I have this error message: failed to open stream: Invalid argument What is wrong in my code? ...

Possible to count number of messages sent via SMTP in PHP?

Bit of a long shot, but is it possible to count how many emails a given SMTP account has sent in an hour? Say [email protected] sends emails via Thunderbird and a PHP script. Can that PHP script first check somehow how many emails have been sent that hour? Obviously the PHP script can easilly keep a tally of how many emails it sends, ...

PHP multiuser login class or script

I am looking for a simple but secure login script with mySQL PHP: sessions, MD5 that I can use with my exsisting database. Cookies to store password + password recovery by email. Change login/pass. I do not need registering, I register the user myself with temp login/pass. table agents agent1 agent2 table albums album1, owner: age...

PHP syntax error

Hi, Can anyone explain to me why the following is resulting in a syntax error (unexpected '=')? protected function processDates() { foreach($this->dates as $name => $unitprefix) { $this->$unitprefix.'year' = ''; $this->$unitprefix.'month' = ''; $this->$unitprefix.'day' = ''; ...

How to set a variable within a mock object

Is there any way to set a class level variable within a mock object? I have the mock object set similar to this: $stub = $this->getMock('SokmeClass', array('method')); $stub->expects($this->once()) ->method('method') ->with($this->equalTo($arg1)); Win the real class there is a variable that needs to be set for it to...

PHP, jQuery and .post(): mysql_real_escape_string messes things up.

Hi! I have been tearing my hair with this one for a while. index.php: $(document).ready(function(){ $(".index_login_subm").click(function(){ uid = $("input:username").val(); pwd = $("input:password").val(); $.post("backend/login.php",{ uid:uid, pwd:pwd },function(data){ ...

php/mysql zip code proximity search

Hi, I'm just looking for suggestions on the best way to do this... I need to create a search function that searches for "users" within a 50 mile radius of a zip code. I have a zip code table that contains all the U.S. zip codes with their latitude/longitude but I'm just trying to figure out the best way to structure and query my data....