php

using nulls in a mysqli prepared statement

In a mysqli prepared statement, a NULL gets turned into '' (in the case of a string) or 0 (in the case of an integer). I would like to store it as a true NULL. Is there any way of doing this? ...

File / Image Replication

Hi, I have a simple question and wish to hear others' experiences regarding which is the best way to replicate images across multiple hosts. I have determined that storing images in the database and then using database replication over multiple hosts would result in maximum availability. The worry I have with the filesystem is the dif...

ajax php variables in javascript

Hello, I have the below code, which was previously working fine: var xmlHttp var layername var url function update(layer, url) { var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere if(xmlHttp==null) { alert("Your browser is not supported?"); } xmlHttp.onreadystatechange = function() { if(...

php parse error

I am using this code: <a href='#' onclick='makewindows(/"".$html."/"); return false;'>Click for full description </a></p> which is part of a much alrger quoted string, which gives this error: Parse error: syntax error, unexpected '"', expecting ',' or ';' in C:\Programme\EasyPHP 2.0b1\www\2\get_auction.php on line 74 The above code...

What's the point of strspn?

At work today we were trying to come up with any reason you would use strspn. I searched google code to see if it's ever been implemented in a useful way and came up blank. I just can't imagine a situation in which I would really need to know the length of the first segment of a string that contains only characters from another string. ...

Using OOP for combining lots of functions (sort of namespace) in PHP?

Hi, I am working with PHP and I am wondering how bad practise it is to combine lots of funtions into a class. I am aware of it's not the purpose of classes, but the reason why I would do this is to provide a namespace. How big impact does it make to initiate let's say 10 classes at the execution of a PHP script isntead of let's say 2 or...

PHP/CURL/Other - How resource intensive?

Hi All, I am going to have a daemon that will run on a FreeBSD server, which will exchange small amounts of data with a list of URIs every minute. I am thinking to use the curl_multi functions to run them all at once, or in groups, every minute, using a post. I am open to other ideas though. I will have to do some benchmarking late...

What does FastCGI: comm with server mean?

I'm getting this error in a PHP (Drupal) application: (104)Connection reset by peer: FastCGI: comm with server "/opt/php-5.2.5/bin/php-cgi" aborted: read failed It is often followed by this error: FastCGI: incomplete headers (0 bytes) received from server "/opt/php-5.2.5/bin/php-cgi" The basic Apache configuration for PHP looks li...

How To Properly Create Domain using Zend Framework?

I asked this question a while back but now I'm looking to implement an actual separation between my database access layer and the domain layer. I am also going to be working to move business logic into the domain where it belongs and out of the controller scripts. I'm using Zend Framework which implements the Table Data Gateway and Row ...

How to Design Domain Layer Objects to Represent Multiple Objects & Single Object in Zend Framework?

I'm working on creating a domain layer in Zend Framework that is separate from the data access layer. The Data Access Layer is composed to two main objects, a Table Data Gateway and a Row Data Gateway. As per Bill Karwin's reply to this earlier question I now have the following code for my domain Person object: class Model_Row_Person { ...

Hide categories that have no products magento

I have many sites that use the same root category of the Main Site. Each product that is added is added to the site it was added to (wow.) and also the Main Site. However, I would like categories on a per site basis to only appear if there are products on that site. If I have: Category1 Category2 Category3 But Site1 only has products...

PHP: Messaging/Logging to Eclipse Console?

Is it possible to send messages from a PHP script to the console in Eclipse? Has anyone attempted this already? I'm not very familiar with how the console works, so I'm not sure if there is a standardized method for communicating with it. ...

Converting a filepath to a url securely and reliably

I'm using php and I have the following code to convert an absolute path to a url. function make_url($path, $secure = false){ return (!$secure ? 'http://' : 'https://').str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['HTTP_HOST'], $path); } My question is basically, is there a better way to do this in terms of security / reliabilit...

Complete AJAX feedback

I build JQuery/JS/PHP/mySQL app with DB records management and need to provide reliable & complete feedback to the user on AJAX calls, modifying back end DB records. The problem IMHO is $.ajax success: and error: functions indicate just AJAX transport layer success and not the whole process. What if BD modification fails? How can one pro...

htmlspecialchars and json encode problem

I am trying to format some bad html to output into a pop window. The html is stored in a field in a mysql database. I have been performing json_encode and htmlspecialchars on the row in the php like so: $html = htmlentities(json_encode($row2['ARTICLE_DESC'])); and calling my makewindows function, which simply takes the html as a para...

Being specialised and keeping up

One of the things mentioned recently maybe in the SO podcast or Joel was that the best way to succeed at business when you start out is to start specialised and concentrate on one thing only. If you say you're the jack of all trades; you're just another jack! If you say you're a specialist in - I think joels example was some type of fau...

Convert utf8-characters to iso-88591 and back in PHP

Hi all. Some of my script are using different encoding, and when I try to combine them, this has becom an issue. But I can't change the encoding they use, instead I want to change the encodig of the result from script A, and use it as parameter in script B. So: is there any simple way to change a string from UTF-8 to ISO-88591 in PHP...

problem in ajax hyperlinking

Dear All, I have problem in giving ajax functionality to hyperlink, I have Link.html & GetCustomerdata.php. The main function of HTml is send the data to getCutomerData.php and shows flash as "success". And also I do not want hyperlinking <a href="#" instead I need in terms of <a href=GetCustomer.php?id=<format> Please anyone h...

Rolling and packing PHP scripts

I was just reading over this thread where the pros and cons of using include_once and require_once were being debated. From that discussion (particularly Ambush Commander's answer), I've taken away the fact(?) that any sort of include in PHP is inherently expensive, since it requires the processor to parse a new file into OP codes and so...

Making PHP scripts time out so they don't kill my server

The cause was probably that I ran out of disk space, causing everything to work strangely. I will leave this question up anyways in case anyone else has a similar issue. I have a few PHP scripts that have hung for a long time, but apparently they are not really using much CPU time as they don't get killed. Still they are making it impos...