php

How to detect whether session_start() has been called in PHP?

Is there such an API? ...

PHP Lazy Load Iterator

I have an iterator class that loops over an array of objects and lazily loads from the database when it needs to (when it's not loaded into memory). Problem is this is iterating around 200,000 times and I found out from here: http://www.garfieldtech.com/blog/magic-benchmarks that the iterator interface is incredibly slow. Would anyone k...

add avatar export to IPB's ssi.php script

Hi all, pretty straightforward question. I want to add the poster's avatar/profile thumb to the output of the ssi.php news case within IPB version 3.0.x... any ideas on how to make this happen? thanks in advance. you are a genius if you can help me. <?php /* +-------------------------------------------------------------------------- ...

PHP: Upload images from client machine to the server.

I want to upload user images from client machine to server in php. The name of the image should be predefined. Can any one tell me the php code for this? ...

Control sort order of files in zip archive

Description I'm interested in learning if there is any way to control sort order of files inside zip files using standard routines in PHP and/or Java. I'm not primarily interested in using zip/unzip using shell_exec() or similar, but it can be of interest if it provides with an easy to read solution. With sort order it's safe to assum...

strange php error

I have the following code: var_dump($cumulitive); $y_axis_max = max($cumulitive)*1.3; var_dump($y_axis_max); It outputs the following: array(16) { [0]=> int(0) [1]=> int(0) [2]=> int(0) [3]=> int(0) [4]=> int(0) [5]=> int(0) [6]=> int(0) [7]=> int(0) [8]=> int(0) [9]=> int(0) [10]...

limiting number of times a loop runs in php

I have a foreach loop that i need to limit to the first 10 items then break out of it. How would i do that here? foreach ($butters->users->user as $user) { $id = $user->id; $name = $user->screen_name; $profimg = $user->profile_image_url; echo "things"; } Would appreciate a detailed explanation as well. ...

mysql_free_result() or mysql_close()

on my site database gets disconnected after few minutes and gets connected after few minutes automaticaly.....i think it is due to exceeding the mysql connections...what should i use mysql_free_result() or mysql_close().....or let me know if there is any other problem.... ...

how to grab a "random" set of items from a loop in php

Im looping through some XML nodes, and say i have between 1 and 200 of these nodes. How can i "randomly" select a maximum of 10 of these nodes. It has to be as most ten, but as few as 1. This is what im working with now... $i = 0; foreach ($butters->users->user as $user) { if($i==10) break; $id ...

how do I manage filenames in my php project

Hello everyone, I have a problem regarding the filenames management in my PHP project. If I have a large number of PHP files in my project and I rename a PHP file then this will result in changing the name of file everywhere where I used the old name for that file. I have adapted a solution to this approach but don't know if it is eff...

Country name from php

Hi How to get country name from an Ip address using Php with out using a commercial GeoIP Region Edition. Please does any one help me? ...

Echo PHP variable from javascript?

I have a php page with some javascript also, but this javascript below doesn't seem to work, or maybe I'm way off! I am trying something like this: var areaOption=document.getElementById("<?php echo @$_POST['annonsera_name']?>"); areaOption.selected=true; Also I have tried this, but it only alerts a BLANK alert-box: alert (<...

Country name from an Ip address with free IP geolocation webservice

Hi , First of all thanks to all .... I read that i can use the free IP geolocation webservice to get Country name from an Ip address. But how i get the response to my site , Actually this is what i look , In my site there is a need of displaying the country name from Ip address. Can uou please tell in detail... How can i display the c...

How do you manage your build [using Phing] process ?

I'm trying to use Phing to automate : running tests running DB migrations on each Developer machine [using dbdeply] deployment to production when needed I think it does make sense to add a build folder in my project and put all my build configuration files and db deltas in that folder. and commit all that into the SVN repository. so ...

How to get the numbers of characters in a string in PHP?

It is UTF-8. For example, 情報 is 2 characters while ラリー ペイジ is 6 characters. ...

How to draw social networking graph?

Hello, I want to implement social networking graph for companies and employees in my PHP CRM System. Do you know any php related technology or else can do this? Thanks a lot. Edit: chart -> graph ...

Is there an conceptual difference between a so called "record set" and an so called "statement"?

I wonder why the result of an SQL query in PHP PDO is called "statement". I'd expect "record set". My english is pretty bad as I'm not a native speaker. So: I craeate a "query" to "ask the database to do/retrieve something". Sometimes I use "prepared statements" to ask that (blue confusion alert!). Then, PDO returns me an object of clas...

PHP mail function giving fatal error but mail is still sent

Hi, I have (what I think) is a simple script to send a short mail: <?php $to = "[email protected]"; $subject = "Amendment required"; $message = "Employee: " . $_POST['employees'] . "<BR /><BR />Notes: " . $_POST['notes'] . "<BR /><BR />Reported By: " . $_POST['empID'] . "."; $from = "[email protected]"; $headers = "MIME-Version: 1....

Wordpress Plugin

Hello, Hope somebody can help me out. I'm trying to use a widget within a plugin in wordpress and I'm seeing this error within the widget box: Warning: extract() [function.extract]: First argument should be an array in /nfs/c03/h04/mnt/57957/domains/rab.qbessi.com/html/wp-content/plugins/register-plus/dash_widget.php on line 24 This...

PHP: $i = $i++ crashed the server

This happened to me a few years ago before I knew about SO, but I'm still curious. When I was still learning the basics of PHP, I accidentally typed $i = $i++; When I tested the webpage in the browser, The server crashed and it took a long time to get it back up. I've typed in some pretty stupid things before and created a bunch of in...