php

Combined HTML, PHP and Javascript indenting and syntax highlighting in vim

Hi all, I use vim for web development. These are almost always .php files, which also contain HTML and sometimes Javascript. While working in a block of PHP, indenting works fine. The syntax highlighting is okay, but only really useful for the PHP-code. When I want to edit an HTML block, I usually switch: :set ft=html, so that highlight...

double qoutes in variables causing javascript error

In my below code when the $artist or $title variables contain " it causes the JavaScript command to break. Is there another way I can encode these other than addslashes() to fix this? $artist = addslashes($row['artist']); $title = addslashes($row['title']); echo '<div class="play" style="display: inline"><a href="javascript:playSong...

How can I upload mp3 files to server in php by ftp?

I want to upload mp3 files to server by using ftp in php language.I did a raw code script for this.In server image,pdf,doc files are uploaded but i can not upload mp3 files. Plz,anyone would help me??I am in serious trouble!!! It shows file does not exist when i am going to upload mp3 files Here is my code,-- <?php // FTP Configurat...

How to ceil, floor and round bcmath numbers?

I need to mimic the exact functionality of the ceil(), floor() and round() functions on bcmath numbers, I've already found a very similar question but unfortunately the answer provided isn't good enough for me since it lacks support for negative numbers and the precision argument for the round() function is missing. I was wondering if a...

Logo change with date script

Hi Folks, I just wondered if anybody can point me in the right direction: I'm looking to make a script whereby the logo on my site changes depending on the date; so for instance a haloween style one soon. I started off by having 2 arrays, 1 of start dates and 1 of end dates(not sure even if this is the best way!): <?php $start_dates...

What else should I be doing to sanitize user input?

Recently, I had an audit run on some of my sites by a client. One of the things they came back with was that I could be sanitizing the input data a little better as people could still cause potential harm to the database. The function below is what I am currently using (a leftover from the old developer) but I cannot see where the pot...

how do i remove a comma off the end of a string?

I want to remove the comma off the end of a string. As it is now i am using $string = substr($string,0,-1); but that only removes the last character of the string. I am adding the string dynamically, so sometimes there is no comma at the end of the string. How can I have PHP remove the comma off the end of the string if there is one a...

Recursively sort array to levels

Hi, I've been working on a site that uses binary mlm system. Illustration here So I have a two tables in database, users anad relationships. There is ID and personal data columns in users. Relationships has 4 columns: ID, parentID, childID, pos. Where pos is either left or right. I have succesfully written a function that recursively...

Can the bin2hex value two different strings be the same?

I am using bin2hex to create unique id's for my users as an Identifier and I don't want to connect to MySQL for checking repetition . ...

how can I get digits from the two digits?

I want to get the single digits from two digits.for example if 36 I need to store 3 and 6 in different variables.Is it possible? ...

Converting XML or HTML to Wiki mark up - what approach would you choose?

I need to convert HTML documents (generated from DocBook XML documents) to the Wiki mark up language, in particular to the PM Wiki mark up language. The goal is to include the company's application operations guides in our newly created wiki. This means that I actually have two options: Convert the HTMLs (generated from DocBook XMLs) t...

PHP Error "canary mismatch on efree"

Appeared a strange error in the error log in PHP, but the script that generated this error is often used and never generated this error, and occurred only once so far. Would anyone tell me why this happened mistake? Error: [client {some IP}] ALERT - canary mismatch on efree() - heap overflow detected (attacker '{some IP}', file '{some s...

file download time log

Is there any way to log (record) the time it takes to download a file from a web server via the browser? The file is written on the HDD and the environment is LAMP. Thanks. ...

Eclipse PDT: How do I get it to format my PHP arrays like VIM?

I've been struggling to get Eclipse to format my php arrays like vim indentation does. What eclipse does (press CTRL+SHIFT+F) <?php $array = array( 'key1' => 'value1', 'key2' => array( 'child_key1' => 'child_value1', 'child_key2' => 'child_value2', ), ); What vim does (press keys:gg=G) <?php $array = array( 'key1' => 'value1', '...

Submitting a form using PHP

I have a submit form with method POST, I want to write a script that can automatically submit this form, the reason why I need this is for testing purposes. I need a lot of data in little time in order to test a search based on those form fields, and I do not have time to mannulally do this. Is this possible? ...

How can I stop Zend_Db_Table_Abstract fetchrow returning garbage data when running tests?

Hi, I'm fairly new to Zend and am having some difficulties with creating my unit tests. I've stripped it down to a minimal test class that still replicates the problem in the hope that it is something daft that I'm doing: class UserRegistrationsTest extends PHPUnit_Framework_TestCase { protected $db; public function __construct($na...

How to get random value out of an array

I have a an array called $ran = array(1,2,3,4); I need to get a random value out of this array and store it in a variable, how can I do this? ...

Doctrine - filter by foreign agregate value

Hi there, how can i use result of Agregate function in where in Doctrine? For example i want to know user with silly much numbers. SELECT u.name, COUNT(p.id) AS users_phonenumber_count FROM users u INNER JOIN phonenumbers p ON p.user_id = u.id WHERE users_phonenumber_count > 10 GROUP BY u.id How can i access the *use...

how to determine which PHP code opens MySQL connections that aren't getting closed

We have an application that is comprised of a couple of off the shelf PHP applications (ExpressionEngine and XCart) as well as our own custom code. I did not do the actual analysis so I don't know precisely how it was determined, but am not surprised to hear that too many MySQL connections are being left unclosed (I am not surprised bec...

Taking a hashed URL and sending it to a new URL

For example, I'd like to have my registration, about and contact pages resolve to different content, but via hash tags: three links one each to the registration, contact and about page - www.site.com/index.php#about www.site.com/index.php#registration www.site.com/index.php#contact Is there a way using Javascript or PHP to resolve t...