php

How to use pear without installation

Hello, I am developing a script for a site using php and I want to use some PEAR classes as they are very helpful to save me from some repeated tasks.The Problem is that I have to deliver the project as a standalone folder that will be placed in an existing website without depending on any server configuration other than PHP 5 and MySQL....

PHP programmers: I would like to optimize the speed at which my PHP scripts execute. What could I do?

I have zlib and Zend Optimizer enabled on my server. I have read about the zlib.output_compression directive. Are there any caveats with turning this directive on in my server? ...

ODBC Connection String for PHP with Obscure Driver

I'm attempting to connect to a database via ODBC, and I am finding no help through Google/the internet. Our ERP uses OMNIS as a framework, which provides an ODBC driver for querying OMNIS' proprietary database outside of the program. I've created the driver and DSN, but I cannot begin manipulating data or sending queries with PHP. The ...

[PHP] Access class with only the name of the class as a string

I am attempting to use an already initialized class in a function with only the string name of the class being passed to said function. Example: class art{ var $moduleInfo = "Hello World"; } $art = new Art; getModuleInfo("art"); function getModuleInfo($moduleName){ //I know I need something to happen right here. I don't...

PHP: Recursive array function

Hi everybody, I want to create a function that returns the full path from a set node, back to the root value. I tried to make a recursive function, but ran out of luck totally. What would be an appropriate way to do this? I assume that a recursive function is the only way? Here's the array: Array ( [0] => Array ( ...

Ajax/PHP - should I use one long running script or polling?

Hello, I have a PHP script that is kicked off via ajax. This PHP script uses exec() to run a separate PHP script via the shell. The script that is called via exec() may take 30 seconds or so to complete. I need to update the UI once it is finished. Which of these options is preferred? a) Leave the HTTP connection open for the 30 se...

Why is PHP's OCI8/Oracle oci_bind_array_by_name not working for me?

I'm trying to bind a php variable to pl/sql array. The pl/sql procedure works fine when I execute it manually and set the bind, so I know that's not the problem. It's the oci_bind_array_by_name that is causing problems. I get the following error message for the line in the PHP code below where I call the oci_bind_array_by_name functio...

Apache mod php and script invocation

Say I am running a PHP script, foo.php, inside apache configured with mod php, then, say I invoke the script from my browser(or any other means), does apache spawn off a new process in which the script gets executed? How does it work? Can someone pls point me to some good article on this? ...

php: determine where function was called from

is there a way to find out, where a function in PHP was called from? example: function epic() { fail(); } function fail() { //at this point, how do i know, that epic() has called this function? } ...

Regexp for selecting spaces between digits and decimal char

I want to remove spaces from strings where the space is preceeded by a digit or a "." and acceded by a digit or ".". I have strings like: "50 .10", "50 . 10", "50. 10" and I want them all to become "50.10" but with an unknown number of digits on either side. I'm trying with lookahead/lookbehind assertions like this: $row = str_replace("...

pagination using php with mysql data

i am trying to create a pagination in which there are 5 items at a time depending on the number of items in DB. i wrote this code . but i dono how to go further .its buggy..any better pagination or alteration for this <?php $myresult .= "<div class='pagination' >"; if ($pagenum == 1) { } else { $pagenum = 1; $myresult .= "<a href='jav...

MySQLi - declaring variable after bind_param?

This may be a completely dumb question, but I've seen a couple examples declaring the variables AFTER putting them in bind_param: http://devzone.zend.com/article/686 I've never seen this done before and all my programming knowledge says I should define them before hand. Is this a valid/preferred way? ...

Lightweight MVC - no framework

Hi sorry if this is a naive question, but what did people do before mvc frameworks became so popular? All you hear of nowadays, and im talking php here, are mvc, Zend etc but what did developers do beforehand? Are there some developers who use the mvc pattern but without a framework - if so how do they do this and is it really complica...

Recompiling php troubles

Hey, so I know there are somewhat similar questions on here, but I haven't been able to get a helpful answer (not that they're not helpful, just not for my specific question) on another thread. Also, I'm not quite sure this isn't a SF question, but here goes: I recently was working on a VPS that had php sans curl. I've tried working ar...

MySQLi - Should every statement be prepared?

I know its supposed to improve performance and clean strings, but lets say there are no variables? Might just be a SELECT COUNT( `column` ) AS count FROM `table` Should that be prepared? Is there any case that a SELECT statement should not be prepared? ...

Is there any way to use imagegrabwindow() with Firefox or Chrome?

I'm trying to generate website thumbnails programatically in PHP. To do this, I'm using imagegrabwindow() with a COM object: $browser = new COM("InternetExplorer.Application"); $handle = $browser->HWND; $browser->Visible = true; $browser->Navigate($pre.$URL); while ($browser->Busy) { com_message_pump(4000); } $img = imagegrabwindow($h...

What is the best way to include a php file as a template?

I have simple template that's html mostly and then pulls some stuff out of SQL via PHP and I want to include this template in three different spots of another php file. What is the best way to do this? Can I include it and then print the contents? Example of template: Price: <?php echo $price ?> and, for example, I have another php...

How to transition from PHP to Python Django?

Here's my background: Decent experience with PHP/MySql. Beginner's experience with OOP Why I want to learn Python Django? I gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes that are shorter t...

MySQL Database Query Problem

I need your help!!!. I need to query a table in my database that has record of goods sold. I want the query to detect a particular product and also calculate the quantity sold. The product are 300 now, but it would increase in the future. Below is a sample of my DB Table ...

Tags php improving database speed and user experience

How did stackOverFlow, excuse me if it wasn't the first implementation of this system. Decide what its initial tags where? I want to provide users with the best experience on my site and am implementing a tags system. I don't care about search engines or any of that. I just care about my users. Does any one have any advice about thing...