I have a particular PHP page that, for various reasons, needs to save ~200 fields to a database. These are 200 separate insert and/or update statements. Now the obvious thing to do is reduce this number but, like I said, for reasons I won't bother going into I can't do this.
I wasn't expecting this problem. Selects seem reasonably pe...
Hello,
I'm working on a CakePHP 1.2 application. I have a model "User" defined with a few HABTM relationships with other tables through a join table.
I'm now tasked with finding User information based on the data stored in one of these HABTM tables. Unfortunately, when the query executes, my condition is rejected with an error about a ...
I have a need to evaluate user-defined logical expressions of arbitrary complexity on some PHP pages. Assuming that form fields are the primary variables, it would need to:
substitute"varibles" for form
fields values;
handle comparison operators,
minimally ==, <, <=, >= and > by
symbol, name (eg eq, lt, le, ge, gt
respectively);
handl...
I have a custom XML schema defined for page display that puts elements on the page by evaluating XML elements on the page. This is currently implemented using the preg regex functions, primarily the excellent preg_replace_callback function, eg:
...
$s = preg_replace_callback("!<field>(.*?)</field>!", replace_field, $s);
...
function r...
Hey everyone,
I'm building a with-source system which I am giving out on the 'net for providing adoptable virtual pets. The system will be owned mainly by kids. Since I want it to be usable for absolute beginner programmers, there are several complexity constraints on my system: It can't use libraries that don't commonly ship with PHP, ...
How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time. An example such query is:
SELECT age, name FROM people WHERE id IN (12, 45, 65, 33)
The IN CLAUSE will have a different number of id's each time it is run.
I have two possible solutions in my mind but want to see if there is a b...
Hi all,
Here's my scenario:
I've got a table of (let's call them) nodes. Primary key on each one is simply "node_id".
I've got a table maintaining a hierarchy of nodes, with only two columns: parent_node_id and child_node_id.
The hierarchy is maintained in a separate table because nodes can have an N:N relationship. That is to say,...
Hi,
I'm trying to scrape a price from a web page using PHP and Regexes. The price will be in the format £123.12 or $123.12 (i.e., pounds or dollars).
I'm loading up the contents using libcurl. The output of which is then going into preg_match_all. So it looks a bit like this:
$contents = curl_exec($curl);
preg_match_all('/(?:\$|£)[0-...
I've been fooling around with PHP, MySQL, JavaScript, CSS, XHTML for about a year, and I still consider myself a beginner. Recently, I decided to start a project and work on it during my winter break from school to improve my skills in webdesign. A couple people recommended that I try and code my own blog.
Can you guys think of other pr...
Every PHP programmer likely uses at least some form of a template engine and a database abstraction layer, but apart from those what extras do you consider essential or would recommend your fellow programmers try out?
...
I have an associative array, ie
$primes = array(
2=>2,
3=>3,
5=>5,
7=>7,
11=>11,
13=>13,
17=>17,
// ...etc
);
then I do
// seek to first prime greater than 10000
reset($primes);
while(next($primes) < 10000) {}
prev($primes);
// iterate until target found
while($p = next($primes)) {
$res = doSomeCalculationsOn($...
I'm attempting to install myphpadmin, but I constantly get errors.
When i type this in the terminal:
sudo dpkg --configure -a
The following message appear:
Setting up mysql-server-5.0 (5.0.45-1ubuntu3) ...
* Stopping MySQL database server mysqld [OK]
* Starting MySQL database server mysqld [...
Well I'm using PHP to generate thumbnails. The problem is that I have a set width and height the thumbnails need to be and often times the images are stretched.
What I'd like is the image to remain at the same proportions and just have black filler (or any color) either on the left & right for tall images or top & bottom for wide image...
I have the string which that encoded in quoted-printable. How do I decode this in php?
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum felis =
pede, vestibulum et, ullamcorper in, ultrices eget, metus. Suspendisse in n=
ulla. Sed justo. Donec dapibus auctor neque. Pellentesque faucibus ante nec=
metus. Vivamus feu...
UPDATE:
Thank you all for your input. Some additional information.
It's really just a small chunk of markup (20 lines) I'm working with and had aimed to to leverage a regex to do the work.
I also do have the ability to hack up the script (an ecommerce one) to insert the classes as the navigation is built. I wanted to limit the number ...
Hey All,
I guess it should be a common technique,
However, I tried the following two options:
1) Using my existing POP3 PHP client to access my local mail account. I am getting a "could not connect". Same code works if I run it with my localhost connecting to GoDaddy's pop3 server
2) Parsing the local mbox file - I can't figure out if...
Hi
I'm using the following as a way of seeing listing the various methods in my developement
print basename(__FILE__) . "::serve_table()"
is there any function that's able to return the name of a class method so I don't have to trpe it each time?
...
I've been developing business apps, basically CRUD, in ASP.Net for years now, and am interested in learning another language and platform.
After a few trips to Borders and poking around a bit on the web, I have not found much dealing with generating reports in PHP. I can imagine, at least, how to generate Excel spreadsheet files, but h...
The singleton is explained here:
http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5.
I want to use the singleton class as a superclass, and extend it in other classes that are supposed to be singletons. The problem is, the superclass makes an instance of itself, not the subclass. Any idea how I can make the Superclass create an instanc...
Well basically I have this script that takes a long time to execute and occasionally times out and leaves semi-complete data floating around my database. (Yes I know in a perfect world I would fix THAT instead of implementing commits and rollbacks but I am forced to not do that)
Here is my basic code (dumbed down for simplicity):
$data...