php

OOP fatal error

What am I doing wrong here folks? <?php include 'header.php'; /** * Display a user's profile */ $id = $db->real_escape_string($_GET['id']); $user_res = $db->query("SELECT * FROM users WHERE id = $id"); $user = $user_res->fetch_assoc(); ?> <h1><?php echo $user['username'] ?>'s Profile</h1> <?php include 'footer.php'; ?> Equals to: ...

Calculate years from date

I'm looking for a function that calculates years from a date in format: 0000-00-00. Found this function, but it wont work. // Calculate the age from a given birth date // Example: GetAge("1986-06-18"); function getAge($Birthdate) { // Explode the date into meaningful variables list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $B...

How do I get only a determined number of words from a string in php?

Here is what I am trying to do. I have a block of text and I would like to extract the first 50 words from the string without cutting off the words in the middle. That is why I would prefer words opposed to characters, then I could just use a left() function. I know the str_word_count($var) function will return the number of words in ...

Problem with login script

Hello, I'm trying to make a login script but I'm stick with a problem: <?php session_start(); if (isset($_POST['username'])) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $query = mysql_query("select id from users where username = '$username' a...

Is there free and good line-level profiler for PHP?

Is there free and good line-level profiler for PHP? I'm using xdebug and it's relatively good but it gives me function level output and sometimes it's hard to see where exactly all the time spent in the function goes. ...

how to implement breadcrumbs using Zend_Navigation

what are the best practices/suggestions/techniques to implement a breadcrumb for a ZendFramework application using Zend_Navigation? how and where is the best method to define the page hierarchy? ...

I need two functions to get CPU Load and Memory load In PHP

HI I need a function to cpu load ( percentage ) and another function to get Memory load In PHP ...

"Universal" search engine for PHP examples

Hello all, There are a lot of web sites for for PHP developers to copy scripts from. I wonder if there is a "universal" search engine to search examples from all of these sites? Something like a Google custom search engine which searches PHP examples from good web sites. My wife needs a tool like that and I guess this question should be...

How much should doctrine record do?

Hello I'm creating my own CMS and use doctrine for database. Now I wonder, when I crate Post record, how much work should that record do? An example: I have Post -> Categories relation (one to many), should I create separate functions to append categories (to look if Post already has category, etc. ) or should Post do that using acc...

Populate Array in Flex Datagrid

I am getting return type as array from PHP. When i populate in my datagrid, the values are not coming... i dont construe why it is happening like this. var appSes:Array = event.result as Array dg.dataProvider = appSes; I am getting the values, from PHP is there anything other than this i have to do. <local:CheckBoxDataGrid id="dg" ...

Can you describe the following PHP function ?

Hello Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = "") { return (is_array($settings_array) && isset($settings_array[$setting_name]) && strlen($settings_array[$setting_name])) ? $settings_array[$setting_name] : $default_value; } What does ...

How to remove the rest of a string

If i have a string like so: Hello - Bye How can i make php find and delete a specifc character and the rest of the string on wards like an example Hello - Bye find the character - and be left with the string Hello ...

While loop combined with header() in PHP

I've written a script to geocode some points which has a structure basically like this: //get an unupdated record $arr_record; while(count($arr_record) > 0) { //strings are derived from $arr_record geocode($string1); geocode($string2); geocode($string3); array_pop($arr_record); } function geocode($string) { //if successful upd...

DNS Lookup in PHP

I have a Windows server that is intermittently losing the ability to lookup DNS information. I'm trying to get to the root cause of the problem but in the mean time I'd like to be able to monitor whether the server can perform lookups. Basically, it should attempt to lookup some common hostnames and the display 'Success' if the lookups...

ORM and Active Record Pattern in PHP?

Hi, There are two things that seem to be popular nowadays and I was wondering what are the pros and cons of using something like this: http://codeigniter.com/user_guide/database/active_record.html ? Another thing is ORM (Doctrine for instance). What are the benefits of using these? ...

Which is a good method for Desktop & web application integration?

I have designed a desktop application in c# and web application in php. my desktop application requests data by calling php file and some portion of desktop application showing web forms using web browser control. both process takes too much time. is there any other method speed up this two processes ...

PHP for .NET

I know there are implementations of Python and of Perl for .NET. Have you ever heard of any similar plans for PHP? ...

PHP Remove URL from string

If I have a string that contains a url (for examples sake, we'll call it $url) such as; $url = "Here is a funny site http://www.tunyurl.com/34934"; How do i remove the URL from the string? Difficulty is, urls might also show up without the http://, such as ; $url = "Here is another funny site www.tinyurl.com/55555"; There is no HTM...

Passing PHP output stream to Java

I am building an app using SOAP/web services to interact with a Java API. All was going swimmingly until now. I need to pass an output stream as a param to a Java method from PHP. I am pretty sure I need to use PHP output buffering and fwrite, I am just not sure how to go about it. I know you can use Java in php by using $myJavaFromPHP...

How does request::is_ajax() work in Kohana?

How does Kohana determine if a request is an AJAX one? Is there anything different in the referrer string? Do I need to add a GET param, perhaps ?ajax=true Thank you. ...