So! Basically I have a database with a load of blog posts, these are all sorted by a UNIX timestamp, and what I need is a way to make this code spit out headers when appropriate, so that it will output something like this:
2008
November
Title 1 - Date Goes Here
Title 2 - Date Goes Here
December
Title 3 - Date Goes Here
2009
Januar...
I cannot figure out a way to skip the next rule if a .php extension exists in the url
Here is what I'm currently using
RewriteCond %{REQUEST_URI} !\.php
RewriteCond %{REQUEST_URI} \/([0-9a-z]*)$ [NC]
RewriteRule ^(.*) index.php?un=$1 [L]
...
I do not know ruby. I am trying to use the following regex that was generated by ruby (namely by http://www.a-k-r.org/abnf/ running on the grammar given rfc1738) in php. It is failing to match in php, but it is successfully matching in ruby. Does anyone see what differences between php's and ruby's handling of regexes that might expla...
I am developing an custom API for a web solution and I am using the MVC design pattern. I have a modules folder so that I can swap in and out modules and also work on sections without disrupting working tested code. My only issue now is that I want to load CSS anywhere and have my application properly import the css file in the head ta...
In my heart, I feel that there must be a super simple recursive solution to this, but I cannot immediately grok it.
I have a tree stored in SQL as a closure table. The tree looks like: (1 (2 (3), 4)), and the languages are MySQL's SQL and PHP 5.3.
The closure table is thus:
+----------+------------+
| ancestor | descendant |
+-------...
Hey!
I am going to start working on a website that has already been built by someone else.
The main script was bought and then adjusted by the lead programmer. The lead has left and I am the only programmer.
Never met the lead and there are no papers, documentation or comments in the code to help me out, also there are many functions ...
Hi,
I'm having a problem with a query prepared in PHP with PDO. The code:
$link = new PDO("mysql:dbname=$dbname;host=127.0.0.1",$username,$password);
$link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $link->prepare("SELECT locality_name FROM :passedday GROUP BY locality_name ORDER BY locality_name DESC");
$query...
Hello all,
I have just succeeded in creating oAuth authentication for my twitter application using PHP.
I then saw this site and I am surprised how they open a new window, close that window and then continue the request in the initial window?! Can Someone explain with some Javascript (I am guessing they are using this) how they did thi...
I'm trying to do some very basic time math - basically, given inputs of time and distance, calculate the speed. I chose to use strtotime() to convert the time inputs into seconds - but I'm getting some bizarre results.
For example, given this sample program:
<?php
$t1 = strtotime("3:15:00",0);
$t2 = strtotime("1:00:00",0);
$t3 = strtot...
Hi,
I'm pulling a list of client names out of one MySQL table to serve as a drop down selection. The data is to be stored on a separate table. I would like the option to come up as selected if there already is a client assigned to the field in the second table.
Also, my radio buttons are inputting their data into the wrong fields, an...
Moodle has a built in per course reset ability. I want to reset all my courses.
...
What's the easiest way to zip, say 2 files, from a folder on the server and force download? Without saving the "zip" to the server.
$zip = new ZipArchive();
//the string "file1" is the name we're assigning the file in the archive
$zip->addFile(file_get_contents($filepath1), 'file1'); //file 1 that you want compressed
$zip->addFi...
I have a code that goes something like:
$cipher_alg = MCRYPT_RIJNDAEL_128;
$decrypted_string = mcrypt_decrypt($cipher_alg, $key,
$encrypted_string , MCRYPT_MODE_CBC, trim(hex2bin(trim($hexiv))));
I worry that in the process of decoding the mcrypt_decrypt will introduce a gratuitous whitespace or null characters at the back or front o...
Hi.
I have a quick question. For the apple push notification service, I need to have my own server, which will send out the push notifications to the apple servers, right?
Can I do this with a simple PHP script on a regular webhosting account, or do I need a dedicated server with full blown admin access for that?
If this is possible i...
I'm writing my own url shortener. I'm done with everything such as creating short urls. But when I try to browse htt p://example.com/rtr93, I get a 404 error. But http://example.com/index.php/rtr93 works find and shows the relevant page (I'm not redirecting to a new url. I'm just getting the relevant record from database which has a colu...
The cms I'm currently working with only supports live editing of data (news, events, blogs, files, etc), and I've been asked to build a system that supports drafting (with moderation) + revision history system. The cms i'm using was developed in house so I'll probably have to code it from scratch.
At every save of a item it would create...
Hi,
I've tried many functions already, but i simply can't figure it out. The right way anyway.
in a form field called description, i can expect all kinds of characters. These need to be formatted into html entities before submitted to the db.
Now, my code:
$formdesc = htmlentities($_POST['formdesc'], ENT_QUOTES);
and for mysql quer...
Hi friends
in my webpage i need to calculate the day[ie. SUN,MON,TUE...] from the date .. The date is in ['06/22/2009'] this format ? How can i calculate it in to day[That is it will show me MON] in php . Please help me to find out . Thanks in advance..
...
Hi, I asked this question before, but not very well! Basically I have an editing page for a CMS, somewhere along the line (from the element onwards) the fields display in the box next to where they should be displaying. any ideas why?
<?php
if(isset($_GET['id']))
{
$query = "SELECT * ".
"FROM studies ".
"...
I have an html form which uses a php file to submit data by email. I want to add some code (which I already have) to generate random numbers for spam protection. Can I call another php file within my form?
Here is the code that goes in the form:
<form name="mail" action="go.php" method="post" onsubmit="return CheckData()">
<input typ...