php

LAMP stack on home computer as a public web server

So I'm using this website: http://www.howtoforge.com/ubuntu_debian_lamp_server to setup LAMP on my Ubuntu Virtual Machine. Here is my question though, This will enable me to program and test through localhost. How can I set this up so anyone on the web can access my .php pages from any Internet capable device, and they will still int...

OLE AUTOMATION WITH PHP or PHP-CLI ?

I read here http://www.daniweb.com/code/snippet217293.html# it is possible. What should be activated in PHP.Ini or elsewhere to make this work ? Are there any examples with Excel ? ...

Change innerHTML of a php DOMElement

How to Change innerHTML of a php DOMElement ? ...

PHP retrieve external program data

Hi, what I want to do is have a PHP script run a program and have it retrieve data somehow from it. For instance the program would parse data from a file and return the data for the PHP script to display. So far I know to call exec("Program.exe"); but would I have to make it create a file with the data then have the PHP script call fope...

Selecting only the first item of an xpath result set in PHP

I am currently achieving the desired outcome with two PHP statements: $thisBlarg = $xmlResource->xpath('//blarg[@ID='.$someBlargID.']'); echo $thisBlarg[0]->name; But, not wanting to settle for second best, I'd really prefer this to be one statement, but PHP doesn't like this: echo $xmlResource->xpath('//blarg[@ID='.$someBlargID.']')...

PHP Game weapon accuracy

I'm trying to come up with a way for players to fire their weapons and only hit for a certain percentage. For example, one gun can only hit 70% of the time while another only hits 34% of the time. So far all I could come up with is weighted arrays. Attempt 1: private function weighted_random(&$weight) { $weights = array(($...

[MySQL/PHP] Avoid using RAND()

So... I have never had a need to do a random SELECT on a MySQL DB until this project I'm working on. After researching it seems the general populous says that using RAND() is a bad idea. I found an article that explains how to do another type of random select. Basically, if I want to select 5 random elements, I should do the following (I...

Test my forms for proper query escaping

CodeIgniter claims do sanitize POST variables. I'm also using DataMapper which I believe also does it's own thing. I would like to double check to make sure it's doing what it's supposed to be doing. How can I do this? I'd like to test this without destroying anything, would typing random escaped characters work? What should I see enter...

"Best" language /architecture for browser-based app with ODBC and sockets? (subjective)

Sorry to ask a subjective question, but I would welcome some advice. I am an experienced programmer of embedded s/w, but haven't done much network programming, although I have done a fair bit of hobbyist PHP. Anyway, I have to develop what is probably a fairly general type of app, as shown in this crude diagram -----------------------...

query mysql table and fetch rows posted in 3 days

Hey guys how can i query my mysql database and fetch rows which are posted in earlier 3 days i know how to fetch todays's rows but not 3 days ago time will save in my table like this : 2010-01-20 19:17:49 and this is what i know : SELECT id FROM pages WHERE date=now() but i need to show posts in 3days and im looking for ...

PHP array manipulation

I have the code below . it looks for the case and creates an array of rows and columns. $pv->results[$row1][1][0] actually is $pv->result->[rownumber][coulmnnumber][0]. Now this is for only 2 columns as you can see. However I want an array like $myArr = array(0=>1, 1=>7, 2=>8, 3=>9 ) to be added below for column. What it is doing, ...

How to compare two file structures in PHP?

I have a function which gives me the complete file structure upto n-level, function getDirectory($path = '.', $ignore = '') { $dirTree = array (); $dirTreeTemp = array (); $ignore[] = '.'; $ignore[] = '..'; $dh = @opendir($path); while (false !== ($file = readdir($dh))) { if (!in_array($file, $ignore))...

incrementing a table column's data by one || mySql

iam having a table with columns like id || counter if i do something (some event) i want the counter's value(at a particular id) to increase by one , currently iam doing this : //get current value current_value = select counter from myTable where id='someValue' // increase value current_value++ //update tabl...

GZIP .htaccess and php session problem

Hi, I am trying to implement GZIP compression for my website. I copied the below code in my .htaccess file: ExpiresActive On ExpiresDefault A604800 Header append Cache-Control "public" <IfModule mod_deflate.c> <FilesMatch "\.(js|css)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> what happens is when I type userna...

What does $$ in php mean?

what does two back to back $ behind a variable means. Like this $$id where can I find more information on that Thanks ...

PHP: MVC and Model

Hello I`ve been wondering this one thing about creating models. If I make for example Page model. Is it the both: It can retrieve one row from the table or all the rows. Somehow Im mixing the objects and the database. I have thought it like this: I would have to make a Page-class that would represent one row in the table. It also would...

Boolean expression in PHP?

case 1: echo false . 'test'; output: test case 2: echo true . 'test'; output: 1test Why true cast to 1 but false nothing? ...

Msword doument to html conversion in php script?

how did write the php script for msword document to html conversion. ...

Need help... how to add md5 to password field in php?

Hi mates, i looking some help and nice attention here.. i bought some php script many years ago and now no suport anymore... i just want to add md5 to password field.. here my form: <?php $SQL = "SELECT * from USERS WHERE USERNAME = '$_SESSION[username]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result ); include...

Getting the variable name of an instantiated class in PHP

Hi, Is it possible to get the variable name used to reference an instantiated class from within the class? here's an example of what i mean: class Test { function getName(){ //some code here to get the name '$test1' in this example } } $test1 = new Test It's not a must for this to be possible, but it'd help for a project ...