php

Anchor tags to plain text within content

I am trying to match <a> tags within my content and replace then with the link text followed by the url in square brackets for a print-version. The following example works if there is only the "href". If the <a> contains another attribute, it matches too much and doesn't return the desired result. How can I match the URL and the link ...

FlashMessenger with Zend - how can I send messages to another user?

Hello, I'm trying to use FlashMessenger to notify another user of an event. Does anyone know if this is possible? Something like $flashMessenger->addMessage( array('status'=> '', 'message'=> 'Hello!'), $user); ...

Parsing XML using PHP - Which includes ampersands and other characters

Hiya, I'm trying to parse an XML file and one of the fields looks like the following: <link>http://foo.com/this-platform/scripts/click.php?var_a=a&amp;var_b=b&amp;varc=http%3A%2F%2Fwww.foo.com%2Fthis-section-here%2Fperf%2F229408%3Fvalue%3D0222%26some_variable%3Dmeee&lt;/link&gt; This seems to break the parser. i think it might be so...

Have a dual-timetable system

Hello, I am trying to do a dual-timetable system thing. Basically, it's for a school project, and some schools have week 1 and week 2 systems. The way this works is through alternating each week, so at the start of september, the school week starts on week 1, and the next week is week 2. How would I implement this in PHP an MySQL? ...

Credit card payment gateway in PHP?

I need to process credit cards and integrate with backend payment services to credit them. The majority of solutions on the internet require an intermediary, eg. 2CO, GCO, Auth.net. Do you have any experience with implementing a credit-card payment gateway in PHP? Any help in appreciated. Thanks for your time. ...

Sort by name, but ignore quotes?

Is there anyway to sort a column by name, and ignore the quotes that being some items? For example: "This is cool" Another article Article 2 Hello Would sort as: Another article Article 2 Hello "This is cool" The quotes are already in the database... ...

Is it possible to create instance and call method in one command (on the same line) in PHP?

Is it possible? Normally, it requires two lines: $instance = new MyClass(); $variable = $instance->method(); Is something like this possible in PHP?: $variable = new MyClass()->method(); Of course, the first code is better for readability and clean code, etc., but I was just curious if you can shrink it. Maybe it could be useful, ...

How to show conditional data in views in MVC frameworks?

How do people generally handle conditional statements in MVC frameworks For some of my pages (made under Kohana) I want the user to have more options depending on whether they are logged in or not, and whether the profile is their own profile for example. From your own experience, do you create separate views, empty variables, do the l...

PHP "backspace" character during output possible?

I have a feeling the answer is "it's not possible," but thought I'd ask to satisfy my curiosity. I have some code that's echoed where the \n is unavoidable: echo "Hello \n"; echo "World!"; I'd like the line to simply read (in the code output): Hello World! ... thus removing the \n. So I was wondering if it's possible to execut...

MySQLdump results in lots of commented lines, no real content

I am trying to write a PHP program to automatically created backups of MySQL tables as sql files on the server: $backup = "$path/$tablename.sql"; $table = "mydbname.mytablename"; exec( sprintf( '/usr/bin/mysqldump --host=%s --user=%s --password=%s %s --quick --lock-tables --add-drop-table > %s', $host, $user, $passw...

php and mysql. WHERE date <= X Hours ago?

I was wondering what is the best way to write the where statement in PHP where targetDate < Date.Now - HardCodedHours in PHP ...

PHP Return results via MySQL Based on timeStamp and the Current time

I'm writing a little bit of PHP, but Im a serious nOOb. I want to compare the current time (The time now) with a timestamp in a table, stored like 1085225495. If the timestamp is under 1 hour old, then do: UPDATE TABLE SET visible=0; Otherwise ignore. Any ideas in php? ...

How can I tell what kind of whitespace is in a string?

I am scraping some information from a 10 year old website that was built in ASP using Frontpage(originally) and Dreamweaver(lately). I am using PHP. I am getting back strings with whitespace that is not spaces. Using the PHP trim function, some of the white space is removed but not all. original string: string(47) " School Calendar" ...

comparing dates in PHP and MYSQL

I am trying to figure out what is the best way to Grab the current date/time (is date('Y-m-d H:i:s') best?) Grab the db date from SQL Check if the current date (#1) is between the date pulled from the DB and 5hours after it I'm a newbie at php. ...

lastInsertId from a bulk insert?

Hy there, Bulk insert question on how to get lastInsertId. INSERT INTO details (idactivity,user,hours,val,date) VALUES ('981','133','0','10500','2008-07-01'),('981','184','0','2750','2008-07-01'),('981','184','0','2750','2008-07-01') (iddetails as details table PK) Is there a way to get the 3 new iddetails and get them to the next bu...

Generating a random seed in PHP for consumption by Flash

I'm working on a project with remote Flash developers, and they have requested that when my PHP application sets up the HTML to load their Flash object, I pass in a seed that they can use to generate random numbers with (the seed is stored so that a particular game can be replayed later). If you were seeding PHP's RNG, you might use the...

What is faster, flat files or a MySQL RAM database?

I need a simple way for multiple running PHP scripts to share data. Should I create a MySQL DB with a RAM storage engine, and share data via that (can multiple scripts connect to the same DB simultaneously?) Or would flat files with one piece of data per line be better? ...

Subtle distinctive features of available CMSes

I know this question would have run across in the minds a lot of people till now, but let me rephrase it according to my doubts. Amongst some of the more popularly known CMS, what are some of the most distinctive features that make you use a particular one? Factors that you can consider are Flexibility (The degrees of websites that can...

problem with counterCache of cakePHP

I have in a video sharing website project these models : class Video extends AppModel { var $name = 'Video'; var $hasAndBelongsToMany = array( 'Tag' => array( 'className' => 'Tag', 'joinTable' => 'videos_tags', 'foreignKey' => 'video_id', 'associationForeignKey' => 'tag_i...

php/mysql client management software?

I'm looking for some software that will allow me to do the following: I don't need anything fancy, just basic information, back and forth dated comments, etc. No payment integration, or file handling. Thought I'd ask before I write my own ...