php

How to Declare timestamp as variable and convert to ddmmyy format.

I have a date issue here. I have a timestamp field in mysql table called filedate. However I have tried several times to declare it and also convert it to a dd-mm-yy format. Unfortunately when I load it the date is still in timestamp format and when I then upload it claims I haven't declared the variable filedate. Any assistance pointin...

Charsets in general, with specific questions regards Zend DB - incorrect display of data.

Hello, I'm having trouble in my Zend Framework App displaying the correct characters. EG/ rue de l'Odéon Displays as: rue de l'Od�on When displaying information through a webservice and also by displaying it through the applications view. I have tryed the following things: 1) Set the character encoding in the view. $view->setEn...

How do I sanitize title URIs?

Hello, I am programming a blog and I want the URIs to be the title like the question title here in stackoverflow or like wordpress. What are the rules for sanitizing a URI? Is there an already made code in PHP that does this? Thanks in advance, Omer ...

Can PHP asynchronously use sockets?

Typical PHP socket functionality is synchronous, and halts the thread when waiting for incoming connections and data. (eg. socket_read and socket_listen) How do I do the same asynchronously? so I can respond to data in a data received event, instead of polling for data, etc. ...

Creating Object instance from Posted data - PHP

Hi All What is the best way of creating and populating an Object from values passed in from a form? If for example, i have a class Car with properties Colour, Model, Make, Year and a method Save, which will either insert or update the record. I then have a form that has fields for all these values and it is submitted. I want to create...

Does socket data need to be error corrected?

When using socket communication in PHP, do I need to confirm if a message has been successfully received after sending each message? Or would the transport layer (TCP) take care of error detection and correction, ensuring successful delivery of any sent messages? ...

How can I connect to MySQL database on a dedicated Windows 2003 server from EC2 based app server with PHP

I have developed a web application that uses PHP and MySQL and has all been running fine from a single development server. I now want to separate things a bit and place an app server within Amazons cloud that will receive and process uploaded files. The database is going to remain on the dedicated server but will need to be accessed by t...

How to safely store a password inside PHP code?

How can I have a password inside PHP code and guarantee that no one viewing the page in the browser can retrieve it? Is, for example, <?php $password = 'password' ?> enough? Is there a better, more secure way of doing this? Thanks. ...

Cookies created with php setcookie() and called through AJAX and XMLHttpRequest disappear on Firefox restart

I'm making a simple ajax login system using cookies to remember username or login automatically on the next visit. Everything works ok, the cookies are set 10 days to the future, I can see them when I go and see Firefox's cookies but they are deleted when I restart the browser. The cookies are set with setcookie() from a php script calle...

Is my form secure? - php

I have a 4 step form process. form.php, validation.php, review.php and complete.php Form.php posts to validate.php which depending on the validation redirects either back to form.php or to review.php. The final step is complete.php Each page is called with HTTPS except validate.php which is where the SESSION variables are created a...

Is CakePHP modeled after Ruby on Rails?

I haven't used Rails, but I'm somewhat familiar with it. I'm more familiar with CakePHP. I get the idea that CakePHP is modeled after Rails, and they seem to have a lot in common. But, basically, I'd like to know if patterning itself after Rails is, or has ever been, one of the goals of CakePHP? I understand it's not a port, but is R...

Yii, yiic and console

In the installation instructions for Yii it is nescessary to use console and command line utility - yiic. Well, on my shared hosting I don't have ssh access. This is why I have following questions: How often and for what reasons will I have to use console? Is there a way to avoid using yiic? May I run yiic on local server and then ju...

PHP/HTML display hidden characters

So, I have a bunch of code that I'm pulling from a column in MySQL. This code includes hidden characters, such as "\t" and "\n". I'm trying to get that raw code to display in a DIV. I was hoping to actually show the hidden characters. I have the following so far, without much luck: <?php // Simple example: replace all newlines with the...

What's wrong with my select query?

I've written this code in order to fetch all the records in a table; however for some reason it's not working: function GetAllData(){ $result = mysql_query("SELECT * FROM a2h_member_type"); while($row = mysql_fetch_array($result)) { echo $row['member_type_id'] . " " . $row['member_type_name'] . " " . $row['descripti...

How come certain values are not being displayed using PHP foreach loop?

I am working on a website using a PHP script to display information formatted a certain way from a MySQL database. I want the date values from the database (which are formatted as YYYY-MM-DD) to be displayed as Month YYYY. The perhaps-not-efficient-enough code I'm using to display the months as words is below: foreach($monthstart as $...

PHP variable from external .php file, inside javascript?

Hi again Masters Of Web Programing. Another maybe stupid question: I have got this javascript for uploading files to my server (named it "upload.js"): function startUpload(){ document.getElementById('upload_form').style.visibility = 'hidden'; return true; } function stopUpload(success){ var result = ''; if (suc...

Upload files outside of webroot

Hello. I'm developing a shopping system where shopmanager should be able to upload files to the system. Those files can the be sold for a fee and should only be accesible through providing a purchase code. The whole purchase code and uploading thing is working fine. Just have to block the direct access to the file. Questions: How ca...

Caching question MySQL or Filesystem

Hi, is there a noticeable speed performance difference when you cache the data which you retrieve from the database to a file on the filesystem (eg.: htdocs/cache/cachefile) rather than grabbing it directy from the MySQL DB? Thanks a lot! ...

How to convert records in a table to xml format in PHP?

I fetched some records from a table named a2h_member in php. i want to convert it into XML format. How can i do this?. Give me some suggestions or code. Please Help me ...

PHP/MySQL - algorithm for "Top Rated"

So I just built a star-rating system and and trying to come up with an algorithm to list the "Top Rated" items. For simplicity, here are the columns: item_name average_rating (a decimal from 1 to 5) num_votes I'm trying to determine the "sweet spot" between number of votes and rating. For example... An item rated (4.6 / 20 votes) sh...