php

What is the best method to output the correct HTML from my PHP loop

Hi guys, I have a problem, I have a HTML problem, I don't know if i'm using the best method, so here is my problem: Everthing is ok:http://screencast.com/t/uJmffaxE If i have more space, here are starting the problems: http://screencast.com/t/1z1GRhOLK Here is my code: <div id="wrap-categories" class="clearfix"> <?php if($this->categori...

PHP string/word processing question

Lets say I have the following sentence: A quick brown fox jumped over a lazy dog. However I have a limit, that only 25 characters can be allowed in that sentence. This might leave me with something like: A quick brown fox jum However, that sentence doesn't make any grammatical sense, so I would prefer to find the last word which we...

Check if jQuery is loaded in PHP

Is there a way to check if jQuery is loaded using PHP? I have two different plugins in Joomla that load the jQuery JS, but when it is included more than once it does not work correctly. To explain the process a bit more: Joomla offers an ability to intercept the HTML source before it is rendered, essentially working on the source code ...

Cron job for big data

Hello guys I'm working on a social network like Friendfeed. so when user add his feeds links I use the cron job to parse each user feeds.Is this possible with big number of users ? like parssing 10.000 links each 1h or can make problems? if isn't possible what the technicals are used on Friendfeed or RSS readers to do that ? ...

mysql LIKE returning only one row when three match.

When I query my database with the following in my file, search.php, it only returns the first result it comes across. $qry = "SELECT business_id FROM business WHERE zip like '%91326%'"; $rs = mysql_query($qry); $rec = mysql_fetch_array($rs); echo $session->showContents($rec); showContents is just a utility function... function showC...

How to listen UDP and make use of PHP

Hello, I have to build up a system which listens for requests from a GPS device which is only capable of sending UDP requests. Then I am going to analyze requests hopefully by PHP if it is possible. I do not know where to start. What do I need? Can I make use of PHP? Would it be reliable to use PHP? Can I just adjust Apache for listen...

Backticking MySQL Entities

I've the following method which allows me to protect MySQL entities: public function Tick($string) { $string = explode('.', str_replace('`', '', $string)); foreach ($string as $key => $value) { if ($value != '*') { $string[$key] = '`' . trim($value) . '`'; } } return implode('.', $string); } ...

Best way to display this in a form?

On my website, I have two tables which are linked using a pivot table. What I am trying to do is let a user update the relationships between the two tables (inserting and removing records from the pivot table). I have no problem doing this in PHP, but what I am concerned about is the way the form is displayed in the users web browser. T...

why can't php just convert quotes to html entities for mysql?

PHP uses "magic quotes" by default but has gotten a lot of flak for it. I understand it will disable it in next major version of PHP. While the arguments against it makes sense, what I don't get it is why not just use the HTML entities to represent quotes instead of stripping and removing slashes? After all, a VAST majority of mySQL is ...

How do PHP's p* connect methods work?

My understanding is that PHP's p* connections is that it keeps a connection persistent between page loads to the service (be it memcache, or a socket etc). But are these connections thread safe? What happens when two pages try to access the same connection at the same time? ...

Printing out Unique Values From Several Tables in Reverse Chronological Order

Hello, I have a MySQL database with multiple tables, each of which have the same structure. The structure is: id INT(11) NOT NULL auto_increment, site VARCHAR(350) NOT NULL, votes_up BIGINT(9) NOT NULL, votes_down BIGINT(9) NOT NULL, PRIMARY KEY(id), UNIQUE (site) The PHP code below prints out each unique "site" from across all the ...

post_max_size and upload_max_filesize on a case by case basis

Using a PHP uploader and was wondering if there was a way to override the default values in php.ini for post_max_size and upload_max_filesize in a specific script? Don't want to change it universally in php.ini because while it's okay to make the limit big on the uploader in our admin section, we don't want that big of a limit in the pu...

MySQL ORDER BY IN()

Hi all, I have a PHP array with numbers of ID's in it. These numbers are already ordered. Now i would like to get my result via the IN() method, to get all of the ID's. However, these ID's should be ordered like in the IN method. For example: IN(4,7,3,8,9) Should give a result like: 4 - Article 4 7 - Article 7 3 - Article 3 ...

PHP relay help and mysql

I have a list of categories on my webpage. They are stored on mysql and each category has an id number next to it. The categories are in divs that when selected change color and whatnot, and when not selected, another color. Only one can be selected at a time. I am trying to figure out how to tell the webpage, which cat has been selec...

How to change from-address when using gmail smtp server

I want to send an email from A to B,with HEADER and CONTENT through gmail. How to do that by PHP? I've specified the FROM([email protected]),but when I receive the email,it's still from my gmail account([email protected]). $mail->From = "[email protected]"; $mail->FromName = "Mailer"; $mail->AddAddress("[email protected]", "Josh Ad...

cakephp .htaccess, mime-types

I have a cakephp 1.2 app (1.2.2.8120) and I am trying to change the mime-type for Japanese cell phones on certain pages with this one line of code in the app/webroot/.htaccess file: AddType application/xhtml+xml .xhtml This works for .xhtml files uploaded directly to the webroot folder, but regular cakephp pages don't work. I have tri...

HTML comment scraping in PHP

Hi there, I've been looking around but have yet to find a solution. I'm trying to scrape an HTML document and get the text between two comments however have been unable to do this successfully so far. I'm using PHP and have tried the PHP Simple DOM parser recommended here many times but can't seem to get it to do what I want. Here's (...

replacing all index.html files in a directory tree

My shared hosting account with a number of websites was compromised. Some malware on my PC, which I probably got through downloading a PDF file, found all my FTP passwords and happily went about its business of inserting some code into all index.* files on the server. I now got rid of this malware, and I am ready to change all FTP passwo...

Check whether an array is empty without using a loop?

Is there any function available in PHP to check whether an array is empty or how can I do this without using loop? For example: $b = array('key1' => '', 'key2' => '', 'key3' => '', 'key4' => ''); How can I check array $b contains empty values without using a loop? ...

Magento - Retrieve products with a specific attribute value

In my block code I am trying to programatically retrieve a list of products that have a attribute with a specific value. Alternately if that is not possible how would one retrieve all products then filter them to just list the products with a specific attribute? ...