php

check in a string php

I have a string and it can contain values like this $string = '1,2,3,4,5'; I wanna put a check that will see if the string contains 4 or 5 if it contains 4 or 5 then I want to echo success otherwise if it contains 9 or 10 I wanna echo fail I know there is a n in_array function but not sure how to use it thanks ...

Parsing XML in PHP with XMLReader - mixed content element - where'd my text go?

I'm having trouble parsing out a piece of plain text; even looping over all nodes with a print-statement, none of them contain the text I wrote in the XML file. Here's the element specification from the DTD: <!ELEMENT question (#PCDATA | choice)*> And here's the data I'm using: <question id="porridge" name="porridge" type="multiple"...

Why won't this javascript work?

It's been really frustrating me i have this code: <script type ="text/javascript"> scriptAr = new Array(); // initializing the javascript array <?php foreach ($docsannlist as $subdocs) { $lines = $subdocs; // read file values as array in php $count = count($subdocs); //this gives the count of array //In the below lines we...

Diff collections of objects in PHP

I often come across a scenario where I have two collections of objects (either array or IteratorAggregate class) and need to diff the two lists. By diff, I mean: Detect duplicate objects (logic for detecting duplicates would vary case-by-case) Add new objects Remove objects that aren't in the other list Essentially, I'm looking for ...

ORM/DAO/DataMapper/ActiveRecord/TableGateway differences?

Can you, please, explain me the differences between the following database representatives, say, in PHP.: ORM DAO DataMapper ActiveRecord TableGateway Any examples would be appreciated. ...

Any 'other' way to SUM variables using PHP?

In a form I have, a consumer can choose to add a blood test, a vision test, or both (combo) to several enrollee's accounts. This is all done at one time. Based on the choice made, I am able to select the 'choice' and echo a respective price but am having the hardest time building a script to 'add or sum' all the variables together. I a...

Integrating a user-facing PHP framework and an admin-facing PHP CMS

My company is looking at various PHP frameworks to build a customer's site. This is a shop that has some legacy in-house frameworks and we're trying to move away from that. In my spare time, I've coded in CodeIgniter and dabbled a bit in Kohana. I have yet to use a CMS like Joomla or Drupal, but I recognize that they're built using an MV...

How to use Stored Procedures with Symfony and Doctrine

Hello I having problems at trying to call a MySQL Stored Procedure with Symfony 1.4 and Doctrine 1.2. What I want to do is the following: In a module/new after typing all the data in the form, I want to insert one of the values in another table. I don't know if this can be done with Doctrine without using a stored procedure. Thank...

WebCalendar Fatal Error message

I recently implemented WebCalendar onto my site and for some reason it stopped working and I now receive the following message when I go to the calendar page: Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 47 bytes) in /data/19/1/87/108/1902760/user/2070591/htdocs/webcalendar/includes/functions.php on li...

Getting the src of a list of images PHP

I know it sounds a bit odd but I have a string: <img src="image1.gif" width="20" height="20"><img src="image3.gif" width="20" height="20"><img src="image2.gif" width="20" height="20"> Is there a easy way to get this into an array of array('image1.gif','image3.gif','image2.gif'); Thanks. ...

how can I import an rss feed from a specific category from one blog and print that rss feed inside the rss feed of another blog?

There are two blogs. The client wants a category from blog 1 to appear in the RSS feed of blog 2. is that possible? would I use something like this? $feed = new SimplePie(); $feed->set_feed_url(array( 'http://simplepie.org/blog/feed/', 'http://feeds.tuaw.com/weblogsinc/tuaw' )); $feed->init(); $feed->handle_content_type(); fo...

Optimize "tagging" regex

I currently use this piece of code to reduce a given text to a valid "tagging" format (only lowercase, a-z and minus allowed) by removing/replacing invalid characters $zip_filename = strtolower($original); $zip_filename = preg_replace("/[^a-zA-Z\-]/g", '-', $zip_filename); //replace invalid chars $zip_filename = ...

Drupal 6: print images in body field content to node template file

In my node-page.tpl.php I print: <?php print $node->content['body']['#value']; ?> However, it doesn't display all body content, it does display all text entered, I use TinyMCE WYSIWYG editor to insert inline images. Visually, editing the node, the images appear in the editor, so I wrote text before and after the image disabling the ri...

Recreate Excel RATE function using Newton's Method

Hi all, I'm working on converting a mortgage calculator in PHP, but I don't necessarily need a PHP solution. I'm looking for the logic needed to replicate the Excel RATE function. I've found a solution which uses bisection, and if worse comes to worse, I use that. I know someone out there in the interwebs world has knowledge of such a ...

Is it possible to preload an entire MyISAM dataset using PHP & jSon?

For Example Let say we have 1000 products in a single category. And we would like to Filter through these products. As we Filter through the products using json. Each time we have need run a separate query to the DB. We were wondering if any one knows if it's possible display a preload the products table. For example preload bar: ini...

Different queries inserting same mobile number?

Hi there, I am currently running these queries: INSERT INTO `action_4_members` (campaign_id, mobile, join_txt, join_txt_date, additional_txt, additional_txt_date, misc_data) VALUES ('15', '6421315710', 'offprem', '2009-12-11 19:32:58', '762355', '2009-12-11 19:33:35', '') INSERT INTO `action_4_members` (campaign_id, mobile, join_txt, j...

passing php variable

I have a PHP array: foreach($xpath->query('//a') as $element) { $linklabel[] = $element->textContent; $link[] = $element->getAttribute("href"); $i=$i+1; } I also have an HTML form: <form name="keypad" id="form" onSubmit="return pass(this)"> <input type="text" size="100%" length="25" value="" name="lcd"> <input type="b...

Updating multiple rows in MySQL

I'm trying to update multiple rows in one table in MySQL database by doing this. And its not working. $query = "UPDATE cart SET cart_qty='300' WHERE cart_id = '21'; UPDATE cart SET cart_qty='200' WHERE cart_id = '23'; UPDATE cart SET cart_qty='100' WHERE cart_id = '24';"; mysql_query($query,$link);// $link is specifi...

encode by php and decode by js

because of gfw(great firewall) in our country , I have to encode content within http transfer (https is better , but its a second choice). my way is use base64 encode by php and decode by js , then show in an iframe. but there's some problem in FF. is there any better way to show base64 encoded string in browser , or another way to enc...

Outputting the name of the month instead of the number

I have a query which returns 3 fields, one of which is the month as a two digit number. I want to basically have it so if month == 1 output january, if month == 02 output febuary etc This is what I am trying, but this does not work at all, and prevent the entire column from being displayed in PHP. while ($row = mysql_fetch...