php

How to dynamically set an increasing value per row in MySQL

I am creating a web application that acts as a priority list, allowing a user to re-arrange a set of items in a list and storing that arrangement in a MySQL database via a PHP backend. At the moment, when the user has finished arranging their items and saves the configuration, I am calling a seperate UPDATE statement for every row, plug...

Scrape and generate RSS feed

I use Simple HTML DOM to scrape a page for the latest news, and then generate an RSS feed using this PHP class. This what I have now: <?php // This is a minimum example of using the class include("FeedWriter.php"); include('simple_html_dom.php'); $html = file_get_html('http://www.website.com'); foreach($html->find('td[width="380...

How do you check if the server is executing the PHP script?

I'm running a cronjob which needs to write data to a cache. I wanted to put this cronjob in my private folder, however, even after CHMODding the cache folder in the private folder, it's not getting writing rights. This seems to be somekind of plesk feature. So, now I've placed the cronjob in the public folder. However, I need to make su...

How to dynamically call a php function in javascript

Hi guys, I have an index.php with the following js function: function returnImageString() { return "<?php include 'inc/image.functions.php'; echo getRandomImages(7); ?>"; //This isn't dynamic; this will always return the same images. How do I fix this? } However, when the page loads, the php script is called and the result...

Mathematical problem: loop or recursive

I´m trying to break a number into an array of numbers (in php) in the way that for example: 25 becomes (16, 8, 1) 8 becomes (8) 11 becomes (8, 2, 1) I don´t know what the correct term is, but I think the idea is clear. My solution with a loop is pretty straightforward: $number = rand(0, 128); $number_array_loop = array();...

php: convert milliseconds to date

I Have a string that is equal to a date, represented as the number of milliseconds since the Unix epoch. I am trying to output it into d-m-Y. The string I was given was "1227643821310", and I am told that the result should be equal to 2-12-2008, but I keep getting a result of 25-11-2008 My code is as follows: $mil = 1227643821310; $s...

PHP UTF-8 questions - If I create a string in PHP... is it in UTF-8?

In PHP, if I create a string like this: $str = "bla bla here is my string"; Will I then be able to use the mbstring functions to operate on that string as UTF8? // Will this work? $str = mb_strlen($str); Further, if I then have another string that I know is UTF-8 (say it was a POSTed form value, or a UTF-8 string from a databa...

What System would you consider a PHP Killer?

(System = programming language, framework, etc.) PHP has some serious benefits, which are ignored by other programming languages and their frameworks. One of them is easy deployment. It feels dirty to just put a file into a directory, which matches the URL. But it's incredible easy and straightforward. No matter what you think of the l...

Flash uploader has its own session id..... why?

Im breaking my head against the table right now. I have a flash batch uploader, which puts every file through upload.php which thumbnails the images, and moves them to appropriate directories. When I upload in IE, it functions perfectly (never thought I'd say this), but in Firefox, when flash executes upload.php it has its own session va...

Career with PHP or ASP.NET?

I started programing in 'Jan 2006', with .NET framework as a desktop application developer. In the same company I worked for exactly two years with VB.NET (desktop and web applications (asp.net)). Actually I changed my job due to some problematic situation in the company. When I was facing these problematic situations my frined offered...

Passing Hebrew encoded text by AJAX (windows 1255)

When making an AJAX call from the client, the server responds with Hebrew text. The PHP page that returns the result is in Windows-1255. For some reason, the result encoding is not Windows-1255, and all I see is gibberish instead of Hebrew. The result purposely contains HTML tags. I've tried urlencoding, base64 encoding, nothing works...

Switching methods for a single result.

Heyall, I have a situation where I require to consult different objects in PHP via different methods to find some data. The question regards more about formatting the code than an actual programming issue. What I am trying to do is not using several if's to gather this data like: $data = obj->getData(); if (!isset($data)) $data = othO...

Fedora 8 howto rebuild custom PHP?

Hello, I am running a wiki server for my group at work and recently moved it to a Fedora 8 OS. Everything works great except that an extension I wrote that contacts an MsSql server fails because the function mssql_connect is not there. On my old server I used "Free TDS" (with ./configure --prefix=/usr/local/freetds --enable-msdblib) an...

CMS similar to Umbraco but in PHP?

Is there a PHP CMS that works the same way as the .NET CMS Umbraco? Ie. All data output comes as XML and is transformed with xslt. And you as a developer have more or less total freedom to create any structure and output as you wish. Reason for asking: Working primarily on OS X / Mac and I'm not very experienced with .NET and the Micro...

How do you hide the url of the .flv file in a flash player?

I use expiring urls to hide the urls of images I use on my sites, so that they can only be hotlinked for the duration of the life of the hash (1 hour). I check the hash sent with the file url, against a hash on the server, if they match, the script calls the following code: if (isset($_GET["hash"])) { $this_min = date('Y-m-d-g',ti...

When is it appropriate to use AJAX?

When is it appropriate to use AJAX? what are the pros and cons of using AJAX? In response to my last question: some people seemed very adamant that I should only use AJAX if the situation was appropriate: Should I add AJAX logic to my PHP classes/scripts? In response to Chad Birch's answer: Yes, I'm referring to when developing a "stan...

Select variable number of random records from MySQL

I want to show a random record from the database. I would like to be able to show X number of random records if I choose. Therefore I need to select the top X records from a randomly selected list of IDs (There will never be more than 500 records involved to choose from, unless the earth dramatically increases in size. Currently there...

How can I implement a voting system on my site limiting votes to a single vote?

I am trying to build a site with news links that can be voted, I have the following code: case 'vote': require_once('auth/auth.php'); if(Auth::isUserLoggedIn()) { require_once('data/article.php'); require_once('includes/helpers.php'); ...

Manage local SVN file structures with PHP

Hello all, I have a developer tool that modifies the local file system using php. These projects are often checked out from SVN. The issue that I would like to avoid is the moving / deleting / renaming of version controlled directoires - and the breakage that occurs to a checked out SVN when doing those alterations locally. Is there...

cURL - Operation not permitted error

Hey, I'm trying to use cURL with PHP and its giving me this error: "Failed to connect to 208.77.188.166: Operation not permitted" I'm pretty sure its a server issue - but just in case, here is my code: <?php $ch = curl_init(); $url ="http://www.example.com"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSF...