php

Add number of days to a date

Hi, I want to add number of days to current date: I am using following code: $i=30; echo $date = strtotime(date("Y-m-d", strtotime($date)) . " +".$i."days"); But instead of getting proper date i am getting this: 2592000 Please help me on this Thanks, Pankaj ...

PHP date format converting

Here is what I have: $dateFormat = 'M d, Y'; $dateString = 'January 23, 2010'; What I need is a timestamp of $dateString so I can do this: $newFormattedDate = date('Y-m-d', $timestamp); I tried to use strtotime function but it tries to find out the format itself and doesn't work always. In my situation I know both the date string a...

How to generate short filenames for uploaded photos?

While uploading new photos to a linux server with PHP, I'm having to give them unique names (using it's file name is ruled out). There's no interaction with a DB so getting unique IDs is also not possible. I thought of using DATE+TIME.jpg, but that's just too long. So what is the best method to create the shortest possible unique na...

Parsing XML on iPhone created in PHP

Hello, i'm trying to parse a xml string with NSXMLParser which i created in PHP. My PHP sript is: $doc = new DomDocument('1.0'); //$doc->preserveWhiteSpace=false; $root = $doc->createElement("root"); $root = $doc->appendChild($root); $child = $doc->createElement("child"); $child = $root->appendChild($child); $value = $doc->createTextNo...

Creating a select dropdown from a .txt?

I've a select menu hardcoded in a wordpress (php) theme, but the manager requires to edit those frequently. Is it possible to populate the select dropdown options from a text file import? So he just has to edit the text file and the menu options would change. The current menu looks like this: <select name="location" id="sort-location" ...

How to get error result of unlink

If a call to unlink() returns false for the specified path, how do you find out what the reason for the failure was (i.e. EISDIR, ENOENT, ELOOP etc.)? PHP 5.x running on redhat linux. ...

Web bot in C++/PHP.

Hello, I've recently started learning PHP, but I have a wide knowledge on C++. I've been wondering how to make a web bot and now, I would greatly like to make one. I won't be using this robot for spamming or anything, just as a test of what PHP/C++ can do online. I was wondering how I could go about doing this and if you have any article...

Hunting cheaters in a voting competition

Currently we are running a competition which proceeds very well. Unfortunately we have all those cheaters back in business who are running scripts which automatically vote for their entries. We already saw some cheaters by looking at the database entries by hand - 5 Star ratings with same browser exactly all 70 minutes for example. Now ...

How to implement MVC from scratch in PHP?

I would like to implement MVC from scratch in PHP because I want full control of my own code and no extra bagage from existing frameworks. Anyone who has any advice? Yes, I've seen Lerdorfs article and it seems that it ain't so much code after all. Actually I would more like to have a controller-view solution for structuring my appli...

Is this php code safe ?

Hi , I am aware I should be using prepared statement's but my next project will be using prepared statement's I just need to finish this simple little application. So my question is: Is this following snippet of code secure ? I have used htmlentities aswell as mysql_real_escape_string because I thought it was a safe option. //Imag...

preg_replace all characters up to a certain one

Hi. I have a string &168491968426|mobile|3|100|1&185601651932|mobile|3|120|1&114192088691|mobile|3|555|5& and i have to delete, say, this part &185601651932|mobile|3|120|1& (starting with amp and ending with amp) knowing only the first number up to vertical line (185601651932) so that in result i would have &168491968426|mobile|3|1...

Checking if a url is already submitted in database in php

Hello everybody, What i need get done is checking if a url is already submitted in database using php. I have a database table where i store URLS submitted by users. But i want to check if the urls are already submitted or not in the database before inserting it to the database. For example, URLS like http://www.example.com, http://www...

What web server should I install?

I have Windows 7 Enterprise and I want to run a web server on this computer and I wander what is the best web server would be in my case. I have several requirements to the web server. It should be easy to install and set up the server. Just "click", "accept" and that's it. It should support MySQL and PHP (with GET, POST, SESSION, and ...

Undefined method error?

Hi All, Joomla,I defined a method function assignRef($key, &$val) { if (is_string($key) && substr($key, 0, 1) != '_') { $this->$key =& $val; return true; } return false; } but when I cal that method I got an fatal error like:WWDatingController::assignRef() It is a Joomla base project. Please provide solution. ...

Using beforeShowDay in JQuery UI Datepicker to close out days of the week

Hi, what I am trying to do is grey out some days of the week for a venue for when it is closed. Each venue might be closed on different days. I can use the following code as a test to close out all Sundays: $('#bookingDatepicker').datepicker({ minDate: 0, maxDate: '+3M', dateFormat: 'DD,...

Modx css issue not pulling in styles on the form

Hi I'm editing a site using Modx cms. I'm trying to add a contact form to the contact page. I already have one in the sidebar specified in a template. The code on the contact page form points to the same div tags, but it isn't picking up any of the css. any ideas why this is happening. Do I need some kind of plugin? Thanks for all yo...

What's this kind of syntax in PHP?

$test= <<<EOF .... EOF; Never see it before,what's it used for? ...

php & mySQL: Query does not use index in table join

Hi, I am trying to list all the book_sales information for a particular book author. So I have a query and it's not using Index to lookup records. The following is my tables structure: -- Table structure for table `books` CREATE TABLE IF NOT EXISTS `books` ( `book_id` int(11) NOT NULL auto_increment, `author_id` int(11) unsigned...

Mysqli select statement not playing well with results from another Mysqli select statement

Below is the code I am using. Separately they both do what they are supposed to but when I try to use the result from the first statement in the second it doesn't return anything. I know that The first statement always returns the correct data. Can someone tell me what it is I'm doing wrong? Thanks $connection = mysqli_connect($hostname...

How to add custom fields for users (like Company:) in Jommla 1.5 ??

I've been searching on the internet for some kind of tutorial to do this and I've only found this one that seems to do the work ( http://tech.nabtron.com/add-custom-field-for-user-data-joomla-1-0-tested/97/ ) but the problem is that this tutorial is focused in Joomla 1.0 and I'm using Joomla 1.5.. the files are not in the same place and ...