php

PHP get line number from logging event

Ok I have another question HERE for my Logging Class but I wanted to be able to add the line number of the calling script to the log file entry. I have seen _Line_ but this gives me the line number of the line where this is at. Example: a.php $log = new Logger(); $log->debug('hello'); // Say this is line #20 Now in my Logger.php cl...

How do you make sure the client gets the 404 error status?

This is actually a two-part question. My server is set up to redirect all 404 errors within Apache itself to index.php?404. Does this still send a 404 status message to the client to tell them the page was not found, and then display my customized 404 error page? Because I also have processes within other pages. While the page itself may...

How to refresh page display while PHP script runs?

I have a function get_forecast() that retrieves weather forecasts for a city, and then runs that function on an array of cities, and then displays all the results on a single page. What I'd like to do is have the display change to show "Fetching forecast for $city" as the script is retrieving each city's data so I can see the progress, i...

How to execute a function at a certain date in a web application ?

I am on a project using php and codeigniter framework. I want to make changes in the database every 3 months. The problem is I don't know how to do it with PHP. I can activate a function when a user access a page, but I want it to be self-executed at certain date. ...

Bash/php - any way to implement tab key autocomplete for arguments?

I have a PHP command line script which kicks off a job to a job server, with the job name being an argument. The job names are namespaced, such as Foo:Bar_Baz_JobName. Is there a way I could implement auto-completion, like how typing the first few letters of a filename and pressing tab bash completes the file name for you. I know it can ...

PHP - BBCode parser - Parse both bbcode link tag and not tagged link

Hello to everyone. I need to do this : when a user insert a BBCode tag, with preg_replace and regex i do some trasformation. e.g. function forumBBCode($str){ $format_search=array( '#\[url=(.*?)\](.*?)\[/url\]#i' ); $format_replace=array( '<a class="lforum" target="_blank" href="$1">$2</a>' ); $str=preg_re...

phpMyAdmin disable admin login

Hi, I have Ubuntu, and installed the phpMyAdmin package (currently 4:3.3.2-1). Every 30 minutes, it asks me to enter my username and password, for inactive session timeout. In earlier version of phpMyAdmin, setting a user/pass would entirely skip this login form and keep the session open indefinitely. This installation is on a dev machin...

how to play an asx file in flash

i need to steam an .ask file form an remote site is it is possible to do in flash ...... .. ...

Checking whether or not a script is running on Apache via PHP

I need to check whether or not an administrative script is already running on Apache, if not then it runs. Currently, I'm loading the server-status contents and checking against it but if I'm checking whether or not the current script is already running it will always return true because I'm running the script to check on itself. Does t...

Retrieving partial content from string in PHP

Hi, I'm trying to figure out a function that recognizes content within brackets and is able to return that content. Like so: $str = "somedynamiccontent[1, 2, 3]" echo function($str); // Will output "1, 2, 3" Anybody here who can help? Thanks for your time. ...

HTTP POST Request using a server proxy in PHP

I'm trying to do an HTTP post request. My server is running a php script with code here <? $siteurl = $_REQUEST['address']; $postdata = ''; $fakeua = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)'; $ch = curl_init($siteurl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_seto...

PHP Real file type

I am building a website where the user can upload mp3 files. And, I want to check if the file is a mp3 file. What I need to know is if there is a php function that do that for me. I tried $_FILES['uploadedfile']['type'] But, I does not work like I want, because it returns the file type based on the extension (I tested it only on windo...

Hide specific class fields from print_r or var_dump

Hi, Is it possible to hide a specific class fields from print_r ? <?php class DataManager { public $data = array(); } class Data { public $manager; public $data = array(); public function Data ($m, $d) { $this->manager = $m; $this->data = $d; } } $manager = new DataManager(); for ($a = 0; $a < 1...

mysql insert escape

I currently have this code $main_cat = "Antiques-collectables"; $mcat = "0187-1443"; $sub_cat = "toys"; mysql_query(" INSERT INTO categories (id, main_cat, sub_cat, mcat) VALUES ('', '$main_cat', '$sub_cat', '$mcat') "); For some reasons the $mcat value is not stored properly . When I check it in the database it appears as "1" ...

Round down to nearest half integer in PHP

I'm pulling my hair out here, so any help would be greatly appreciated. I need a php function that will take a float and round it down to the nearest half (x.0 or x.5). I found other functions that will round to the nearest fraction, but they round both ways. The function I need can only round down. Examples: 7.778 = 7.5 7.501 = 7.5 ...

Doctrine: Change date format when getting and setting field values

Hello: I want to be able to get and set the date using my own date format (dd/mm/yyyy) and not doctrine (yyyy-mm-dd). I've found a way that is specifying a getter and setter for every date field however I want do it in a more convenient way (1 setter + 1 getter for every date field in every table is a lot) class Curs extends BaseCurs {...

PHP - Canny Edge Detection class

Hi, Been looking all over and figure I'd ask here. Has anyone ever seen an open source canny edge detection class written in PHP. Found that PHP5 with GD has an imagefilter with edge detection capability, but doesn't quite match what I need. Thanks, Tee ...

Sending a notification when a MySql database entry changes

I've written a php file that changes a MySql table entry when it receives an http post. I would also like the php file to send out a notification to the table entry's owner. This idea is similar to a chat room or instant messengering program. I've looked at php chat scripts but I really need something that has a very simple interface tha...

Zend DB and encoding

Hi guys I have just encountered something rather strange, I use the Zend Framework 1.10 with the Zend_Db_Table module to read some data from a databse. The database itself, the table and the fields in question all have their collation set to "utf8_general_ci" and all special chars appear correctly formatted in the DB when checked with p...

fsockopen not working?

I am trying to connect to an IRC server via PHP on a command line using Windows 7. Everytime when running this: $socket = fsockopen($irc_server, 6667, $errno, $errstr, 5); $errno = 0, $errstr = "" and $socket = 'Resource id #4' (using die($socket);) What is the cause of this, and how can I debug more into this. The following code: ...