php

How does Ruby and PHP differ in their evaluation engines?

I once found an article with the differences between how PHP and Ruby handle different types of variables matched with certain testing conditions (ie: isempty, isset, etc). How do they differ? ...

How to preload a div combobox in jquery

i have code as follows: $("#item_select").change(function() { var params = $("#item_select option:selected").val(); $.post('/account/ar_form.php', {idata: params}, function(data){ $("#message_display" ).html(data); }); }); This is a dropdown that uses /account/ar_form.php to display html in the div correctly. B...

How to get the number of times a string is repeated in PHP

In a string like "abc fox fox fox ghi xyz" how can i get the number of times 'fox' is repeated in the string? ...

Building a RSS feed with links embedded

Edit: I have this line: $comments = "http://www.kiubbo.com/index.php?action=comments&amp;param=".$articles[$index]-&gt;getId(); And if I put it here it works out in the title tag, but not on the link or guid tags. fwrite ($fp, "<item>\n"); fwrite ($fp, " <title>$title</title>\n"); fwrite ($fp, " <link>$comments</link>\n"); fwrite ($...

Do memcache clients of different languages hash the same way?

We would like to some processing in a Java application, store the results in our pool of memcache servers, and read it back using memcache in PHP. This is easy enough to try, but I though I would ask and see if anyone else has done this. As long as both the Java and PHP clients connect to the same pool of memcache servers, will both cl...

how to get the cookies from a php curl into a variable

So some guy at some other company thought it would be awesome if instead of using soap or xml-rpc or rest or any other reasonable communication protocol he just embedded all of his response as cookies in the header. I need to pull these cookies out as hopefully an array from this curl response. If I have to waste a bunch of my life wri...

apc_define_constants vs hidef vs define

Has anyone used apc_define_constants or hidef vs using define. Any true benefits or possible bugs in the latest versions? apc-define-constants - http://us2.php.net/manual/en/function.apc-define-constants.php hidef - http://pecl.php.net/package/hidef ...

Problem with SQL statement using PHP

I'm currently trying to pull data from MYSQL using PHP and I keep getting the following error: "Could not retrieve records: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%PC4198% OR oem LIKE %Fluke%' at line 1 " My SQL statement is as follows: $sq...

MYSQL SUM by QTY's And Values

Hi All I would like to know if its possible to get 2 sums from one query using the table values and then add them togther. Here is some simple table & data which might help. CREATE TABLE `cartcontents` ( `id` int(11) NOT NULL auto_increment, `code` varchar(40) NOT NULL, `qty` int(10) NOT NULL, `price` decimal(30,2) NOT NUL...

display mysql results on same page

Ok, so I'm used to working with C# and ASP.NET which automatically allows one to display database results immediately on the same page from which they were requested. I am, however, now using PHP which I haven't coded in in years. I have the results popping up in a separate page because the form tag's 'action' option is set to that spec...

array_slice() warning in php and wordpress

I write this code function get_feed(){ // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss('http://dorar.shamekh.ws/?feed=rss2'); $maxitems = 1; $items = array_slice($rss->items, 0, $maxitems,false); return $items; } ass a part of plugin for wordpress , its work fine in my local server , but when I uploa...

PHP Outputting File Attachments with Headers

After reading a few posts here I formulated this function which is sort of a mishmash of a bunch of others: function outputFile( $filePath, $fileName, $mimeType = '' ) { // Setup $mimeTypes = array( 'pdf' => 'application/pdf', 'txt' => 'text/plain', 'html' => 'text/html', 'exe' => 'application/oct...

Is there an equivalent to PHP's `date_default_timezone_set()` that works in MySQL?

This works great in PHP date_default_timezone_set('my/timezone'); $actualDate = date('Y-m-d'); Now when doing queries, I like to do INSERT INTO articles (title, insert_date) VALUES ('My Title', now()) The problem with this is the now() in the MySQL is different to what it would be had it been calculated in PHP (and therefore again...

Does an overloaded __get need to manage all member variables?

I am creating a __get() function for a class to control access to my private member variables. Do I need to design the function to handle all possible member value reads or can I not write it for members that are public? Also, I am assuming that classes that inherit this class will use my __get() function to access private members. cl...

compare results with another table in PHP/MySQL

I have 2 tables... Table1: ID, Name, Country Table2: ID, accountID, parent table1.id = table2.acountID My script does a search for all records with a particular parent. I want to compare those results with table1 and return all entries that wern't in the search. eg. Table1: 1, Bill, AU 2, Charles, US 3, Clare, CA Table2: 1, 1...

PHP & SQL Server - field names truncated

I have discovered that results coming from my SQL Server are having the field names truncated: $query = "SELECT some_really_really_long_field_name FROM ..." ... print_r($row); array( 'some_really_really_long_field_n' => 'value' ) Does anyone know how to avoid this behaviour? I think the database driver is ADODB. So you don't ha...

array in MySQL

...

social graph problem (path between users)

I have received the task to make a social graph, where, with one user in the center, it shows the connections he has. But before we can reach that, our focus is how we can determine the shortest path between 2 users. I found some algorithm to do it, but it seems that it takes a lot of time, and because it's about social links, we are loo...

Newbie Question-- calling multiple .sql scripts into PHP file

I have a PHP file that executes multiple sql scripts. I find that the first two scripts execute, but the last two never seem to complete. I tested the last two scripts individually in their own PHP files and the scripts worked, so I'm wondering if it's because of the number of exec() calls I'm making in my PHP script. Any suggestions? He...

How to use twitter api with "http basic auth"?

Hello How to use twitter api with "http basic auth"? I think I should use the "consumer key"! because twitter gave you limit rate of requests per hour, how can they count my requests if I didn't use my consumer key? ...