Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Filtering A Db With A Start And End Date


I have a MySQL table with a datetime field. I need to make a PHP script that will take all rows whose datetime field falls within that of a user-specified begin and end time. Anyone have a code snippet to do that?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Start Date - End Date = Number Of Days
I have a starting date for var 1 and today’s date for var 2. I need to calculate how many days are between those two dates.

02/24/03(today) - 01/14/2002(start date) = number of days.

In theory this is easy but there are many instances were I could get an inaccurate answer. For example one consideration is that some months have 30 days others have 31. exc.

My question is, is there an easier way to solve this problem other than using endless if statments to error handle all possible instances? Does PHP4 have any built in functions that could calculate this formula correctly?

Filtering Results By DATE Value In Database
I have this code in my page for displaying some data from a database, sorted by date. i had posted a messed up version of this a while ago but I couldnt get it working even after a few suggestions. PHP Code:

Using The Date Function To Find Last Week Start And End.
I need to find the start of last week (monday) and the end of last week (sunday) using the date function in a Y-m-d format.

But it needs to work this out regardless of todays date.

Finding a day in the past is not a problem if you know how many days to minus from the date function, but how can I work this to be not dependent on this fact?

Start Date End Date
I am creating a simple auction site. There will be a start date which I think will be a timestamp and an end date. How can I do code the end date so that it is $days until it closes? I am not asking for code (although that may be helpful) I am asking for an explanation.

Warning: Session Start() [function.session-start]: Open(/tmp/sess 8b10
Hello. Could someone tell me why i am getting these warnings on my php pages? And what i can do to fix it? Thanks.

Warning: session_start() [function.session-start]: open(/tmp/sess_8b107ef6a1cde0a7426aedc044c14cb2, O_RDWR) failed: Disk quota exceeded (122) in /home/ployjam/public_html/admin/login.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/ployjam/public_html/admin/login.php:2) in /home/ployjam/public_html/admin/login.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ployjam/public_html/admin/login.php:2) in /home/ployjam/public_html/admin/login.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at /home/ployjam/public_html/admin/login.php:2) in /home/ployjam/public_html/admin/login.php on line 23

Warning: Unknown: open(/tmp/sess_8b107ef6a1cde0a7426aedc044c14cb2, O_RDWR) failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0

Filtering HTML With PHP
I am using PHP to set up a message board which interfaces with a mySQL database. I am trying to filter malicious HTML code that users would try to leave on the message board. I want to strip all HTML tags except the <A HREF> tag.

Filtering Out Bad Input
I am currently building a website, with a built in news and comment, so far i know have been able to filter out thing such as swear words, however is it possible to filter of say f someone held down the ===================================================== ============= key

Is there a way to prevent this or will i have to have some sort of statement that counts how many times the = or other char is grouped together?

Filtering RSS Content
I need to install an rss aggregator on a website. The catch is that it
should only pull in items from feeds which contain certain keywords.

Any idea how this can be done or if such a content managing software
already exists?


Dirty Filtering
does any one has a list of dirty words, do not post in this forum, but show me url. PHP Code:

Username Filtering
I'm having problems with regular expressions. How could i check if a variable has only letters and numbers in it?

Price Filtering
I am having an issue with filtering price from a form variable so maybe someone can tell me how I'm screwing this up.

I have a search page that has 3 criterias for search - category 'cat', price 'price' and location 'area'. I am using Dreamweaver 8 for this project. I can create the query for both cat and area for the double filter, but when i get to price it removes all the records from view.

I removed the 2 working queries and am now focusing on the 'price' query. My SQL looks something like this: Code:

Filtering Data
I've got a question which is more aimed at drumming up some opinions/starting a discussion then looking for a "right answer".  I am writing an application and I wanted to hear some suggestions on how to handle the filtering of data from the user.  The data is all coming in through one class where it is then passed as arguments to methods down the hierarchy, so it seems to make sense to do the checking at that top point.

However what isn't as clear is whether the regular expressions (or some alternative) used should be exclusively set by the top level class.  For instance I see that Cake (a framework) has a protected _validation array which Models can set with their own regex.

I am not a huge fan of this approach because it leaves the array protected, and because it may be responsibility that goes past the role of the class.  In fact I'd prefer a method which didn't rely so heavily on regex in the first place as I find regex hard to maintain.

So what solutions have you come up with to handle input?  I'm looking for suggestions which are flexible enough to accomodate unforseen changes in security, but simple enough to be implemented in a single class (or a single method).

To kick this off here's my current solution (somewhat described above)
if (!is_array($this->_validation))
throw new Exception("Unable to validate data bad validation hash found");

$result = array();
foreach ($arguments as $key => $value)
{
$pattern = $this->_validation[$key];
if ($pattern == null)
throw new Exception("The submitted data has no corresponding pattern and can not be evaluated");
if (!preg_match($pattern, $value))
throw new Exception("The submitted data was invalid");
$result[$key] = $value;
}
return $result;

IP Filtering By Country
Does anyone know of some good ways to filter traffic by country?

I can only monetize US, UK, and Canada traffic, but must send them to a different thing for each country.

All other countries I would like to send somewhere else.

Filtering XML Results
I'm in the process of creating a page that displays multiple lines of inventory for a bunch of products (let's call them 'widgets'). The widgets are listed in XML format (they'll end up being pulled from a MySQL DB eventually). Code:

Filtering Of Characters
Does filtering of certain characters make a search engine more efficient?

Speical characters such as ~!@#$%^&*()_+

Error Filtering Bad Language
I have a dynamic shout box service, and I need to filter bad language, so i wrote a function on how it should work. PHP Code:

Filtering Out Keywords In A Search!
I have about 1100 movie titles in a database. I am trying to do a simple search engine and have seperated each keyword using the following code:

$q = $_GET['q'];
if ($q) {
$q = strtolower($q);
$k = split(" ", $q);
$num_keywords = count($k);
for ($i=0; $i<$num_keywords; $i++) {
if ($i) {
$search_string .= "OR moviename LIKE '%" . $k[$i] . "%' "; }
else {
$search_string .= "moviename LIKE '%" . $k[$i] . "%' "; }
} end for
$and .= "WHERE ($search_string) ";
} //end if

$querycount = "SELECT * FROM titles $and";

rest of code...
This works ok, but if I type something in like 'The Killer' it fetches everything with the word 'the' as well.

I have put the words into an array that I want to filter out.

$skipwords = array("the", "of", "and"); etc

Can I use that to filter out the words? I`ve been playing around with the in_array() function, but can`t seem to get it to work like I want it to.

Audio Filtering Via PHP, Program
I have been tasked with trying to find a way to complete this
project... I'm not sure if it is possible, but hopefully you guys can
provide some insight...

I need to create a web application that will allow a visitor to record
their voice into an audio file, then apply different filters/effects
to it (like robot, lady, etc.), and send it to a friend. I haven't the
slightest clue where to begin on doing something such as this. I
searched google for a similar functionality, and have come up empty
handed. Has anyone seen anything like this done, or an application
that would do something like this, PHP or otherwise?

DVD Id Is Incorrect After Filtering Results
I am making a basic DVD shop and after having produced code which displays a
list of DVDs from my database, I implemented a search facility which enables
the user to search by title, director or actor.

The user can also browse the DVDs by genre. However, when the DVDs are
filtered, the id that is used to select a DVD and add it to the basket is
incorrect as they are output in a sequential manner and so the DVD placed
into the basket will be that matching the id. Here is the loop that outputs
the DVDs (I have a DVDID field as you probably have guessed):

if (mysql_num_rows ($getdvds_query))
{
for ($id = 0; $dvd[] = mysql_fetch_assoc ($getdvds_query); $id++)
{
echo "<tr>
";
echo "<td>{$dvd[$id][title]}</td>
";
echo "<td>{$dvd[$id][duration]}</td>
";
echo "<td>{$dvd[$id][rel]}</td>
";
echo "<td>{$dvd[$id][descr]}</td>
";
echo "<td>{$dvd[$id][genre]}</td>
";
echo "<td>{$dvd[$id][stock]}</td>
";
echo "<td>{$dvd[$id][price]}</td>
";

echo "<td><a href="$PHP_SELF?add=$id">add to basket</a></td>";
echo "</tr>
";
}
}

Here is the code that adds to the basket variable:

if (isset ($_GET['add']))
$_SESSION['trolley'][] = $_GET['add'];
else if ($_GET['op'] === 'clear')
$_SESSION['trolley'] = "";

HTTP Filtering With PHP & Apache ?
I am looking for a full example how I can achieve an http output
filtering with php on an apache 2 server. I found some hints that the
apache server supports to isntall and conifugrate such filters
http://httpd.apache.org/docs/2.0/mo...addoutputfilter
But I didn't found an example which is related to PHP.

I like to achieve for my shop using a template mechanism based on xml &
xsl with PHP. My idea is currently to use an output filter which does
the xsl transformation.
If anybody knows a tutorial or even some applicable frameworks in this
area please post me here the links.

User Input Filtering
I have a comments system. In this comment system, people can enter certain strings, and it will break my page layout. Such as repeated characters with no spaces. It will just blow the table way out of proportion and completely ruin my layout. How can I break their input up if such a thing happens? Also, how can you number an array of data that is being withdrawn from the database DESC? Such as..

Quote1. itemnumber1
2. itemnumber2
3. itemnumber3
4. itemnumber4

Filtering Results With Php Query
This code works, but I don't know how to filter the results to where only one person is displayed..it displays all records with similar address or state or city, I would like to know how to make it display only one person when multiple search fields are entered.

I'm using PHP5, and I have searched the forums but I'm not sure exactly if I found what I'm looking for...I don't know much about php or mysql. Code:

Filtering Message From The Database
i have a page where people can send in MMS pictures and they get uploaded and displayed on my page, they need to type a keyword in the MMS like "sendmms" to make it work. if they also write "sendmms hey look at me" it also works since "sendmms" was at the beginning of the message and "sendmms hey look at me" get's added to the row "message" in my database. the pictures get an ID in the database and saved with the same ID on the server.

so under each picture sent in i wanted to add the comment they added after the "senmms" part.

so in short, how do i make it filter out "sendmms" and only display "hey look at me" ? and if the Page ID is let's say 13 it should display the "messsage" column for the ID in the database that has the same ID as the page ID is.

Filtering User Input...
I want to take text that a user inputs and store it into a variable.  That's the easy part.
I have and array of 30 elements that I want to store the inputted text into.

So.. here's an example...
- I want a user to enter text.
- I'll store it into a variable like $inputText.
- I want to split the text from $inputText into 30 equal sections and store each section into an element in the variable.
- I don't care if the words get separated during the filter, as long as the whitespaces stay where they are.

Could anyone give me some tips to help me get started or point me towards a tutorial or something?

Filtering A Recordset With A Session Variable
I have two forms, the Form1 and the Form2. One of the answers in the Form1 is saved in a session variable SesVar1.

In the Form2 there is a dynamic table build with a recordset. I need to filter the recordset of the Form2 with SesVar1.

I tryied to do this using a variable in the recordset window of dreamweaver, writing #SesVar1# in the run-time value of the variables for the recordset, but it didn't work.

Please HELP me out with this one. How can I filter that recordset using the value of a session variable? or the Form1's answer?

Image File Upload Filtering
I have made a file uploader,

I also made a filter, I can't make a good filter for jpeg files, but i can filter gif, can you advice, thanks

if ($_FILES["file".]["type"] == "image/gif")
bla bla bla

Filtering Selection In Multiple Drop Down Boxes
I want to allow a user to conduct a search on a database using multiple drop down boxes.
On the first page they will have a drop box filled with records from field A. Once they select which one they want, a second drop down box will then appear with records from field B which are present for field A (a filter).

What I want though is that the first dwon down box still appears on the second page, but shows the record that the user selected. What is happening now is that when the second page comes up, the first box shows the default selection rather than the selection that the user chose. My code for the drop down boxes is: PHP Code:

Filtering The Elements Of A Multi-dimensional Array
I would like to be able to filter every element of a multi-dimensional array
using htmlspecialchars() and to retain the structure of the array. I can't
see how to do this when I don't know how many dimensions the array has.

Dynamic Recursive/nested Foreach (part Deux) With Filtering
I originally wanted to figure a method to better implement a nested foreach to calculate all the permutations held within an array. After posting the topic and getting great responses an elegant solution was found. I then increased the difficulty by requesting that we also include a method to "filter" or "skip" certain values during permutation calculation. The original solution finder quickly came back with yet another code snippet listed below which acomplished the request...it was mere childs play it seems for them (sasa). I marked the topic solved as the original question had been solved.

I am creating this new thread as I am once again adding an additional layer of difficulty. The final previous solution is listed first as a reference, followed by the new and more complex problem underneath that one. My attempts to shunt in the functionality have all failed I think due to the recursive nature...any takers? Code:

Better To Start With <? Or <?php
Is starting with <? the same as <?php . The reason I asked was that after reading a few tutorials I have seen them both use <? and <?php sometimes. Why not use <? since its only 2 chars compared to 5?

Not Sure Where To Start
I have a page with the letters ABCDE...etc
I want to be able to click on a letter and it will bring up a list of
title's to click on, so how do I get it to load a page if say A was
index.php?reviews=a

I've already got the page with the links in and that then loads the reviews
up if you click on the link, but I've made 26 pages areview, breview,
creview etc. I would just rather have a common page that would choose the
right one.

Is this a simple answer or is it going to be complex?



Where To Start Learning OO In PHP ?
like to learning OOP in PHP , but i dont know where i must start to learning.
can somebody give me advice ...

Best Way To Start Learning...?
Alright, I need to learn PHP, but honestly I'm having trouble with some
of the online tutorials for two reasons:

1. They're incredibly dry and tend to just say what things do instead
of going in-depth into examples.
2. They don't provide me with excercises and projects in which to test
out what I've learned. The best books I've ever read on any form of
scripting, coding, programming, etc. give me tasks in which to use what
I've been taught. I only learn well by doing, not simply by being
presented with facts.

So... is there a site and/or a book (I'm willing to buy one if
necessary) that you would recommend for someone like me?

As a side note, a lot of them seem to put a lot of time and effort into
instructions on setting up PHP, Apache, and MySQL. I have a web host
that's already fully configured (and runs PHP as CGI, although Apache
is an available method that goes against their recommendation)

Want To Start Tomcat From Php
i wan tto start jakarta-tomcat-5.5.3 from the webbrowser using the
sheel scripts...i normally use the shell scripts from the command line
to start and stop the tomcat server.....

i found out that php gives this incredible facility where i can execute
normal bash commands...i tried doing so ..but a simple command like {
system('whoami') } from
browser......eg.....http://localhost/startup.php..

prints apache as the user....so technically it executes the tomcat
startup script as apache user..but ive got
jakarta-tomcat-5.5.3 under the tomcat user....can someone please tell
me is there a way in php coding wherein i can execute the command as
another....i know this seems a bit out of place...but i really didnt
know anywhere else to go

PHP Script At Start Up
I would like to run a script at startup under SuSE 9. I read and
figured out that it can be done using chkconfig and setting the proper
run level. The problem I have currently is that I depend on system
environmental variables being available for PHP. I am using PHP as a
scripting language (nothing to do with the web), and this PHP script
is called from the start up bash script, but it cannot retrieve any
environmental vars at runlevel 3.

When are environmental vars set and at which runlevel? Or should I do
this some other way?

Newbie Looking Where To Start
After being a lurker in here for some time, I got the PHP bug, and
downloaded Apache 2.0, PHP 4.summat and MySQL

I installed, registered the dll's edited the conf files and finally got it
all working (i think) after a few nights of faffing about.

Now... where should i start? I know naff all about PHP or MySQL and would be
greatful if someone could point me in the direction of some tutorials to
start learning about PHP and MySQL.

I am from a programming background (visual basic) and have a welly load of
knoledge on relational databases so wheres the best sources...
Book/Web/Forums etc...

Fopen Start On New Row?
is it possible to have fopen start on new row?

fopen("$filename","aw");

i've been trying to write to the end or beginning, doesn't really matter, of a .txt file, but it just writes on the same row as the last input.

How To Start Session?
i m learning how to have session in my form. like for example, after the user insert their information in the application form, they will then be redirected to another page. the another page is where they will have to print out their form - with their info added in. but i m unsure how to go about doing it. can someone show me?

When Does HTTPS Start?
This might seem obvious, but do you have to establish an https connection before a form is sent, or can you send the form to an https connection and have it encrypted? For some reason, I never looked into this - I just always sent the form to the user via https to be sure - and to be honest it really doesn't matter that much, but I'm just curious. Code:

How To Start Learning PHP
I am working website recently and new to it.Please mail me how to learn best?

Start And Stop Apache With PHP
Is it possible to start and stop a server using a link button. Is there any PHP function to control the server starting and stopping. I have a small function to check the server status.

This is it below
// This function checks to see the status of the servers
function check_server($ip){
$fp = fsockopen ("$ip", 1111, $errno, $errstr, 30);
if (!$fp){
echo "<td bgcolor=red><FONT face=arial, helvetica size=2 color=white>DOWN</font></td>";
}
else{
echo "<td bgcolor=green><FONT face=arial, helvetica size=2 color=white>UP</font></td>";
fclose($fp);
}
}

I now want to either have a method to either stop or start the server depending on its status.

Inserting At Start Of Array
I am trying to insert an item at the start of an already populated array but I cannot seem to find a way of doing it.
Here is an example of what I am trying to do:

How To Delay The Start Of A Function
My problem is that a function in the page have a rather heavy mysql query.
The query takes between 6 - 10 seconds. while the query takes place other
content on the page stop loading (Opera). Explorer and Firefox seems to
wait for the whole page to load befor drawing the site.

Is there a way to tell the browser to draw all the content except for this
function and run through this at the end, alternatively to run the process
in backround?

This functionality a want is on many sites who let you search through
multiple whois databases.

Record A Session's Start And End
how can i record the time a session started and ended. by ended i mean. ended in any way. browser closed, logout link clicked. or session expired. i thought to do

if (session_register('var1','var2'))
{ // record time }

but register_globals is off. can i still use that? and i still dont know how to record the ending.

Php Kick-start Required
Sorry to barge in like this but I'd really appreciate any pointers for a
seasoned veteran of programming (including C, Java, ASP, JSP, Perl, shell,
VB, HTML, XSL) who has never touched PHP before.

I've rather rashly agreed to doing some enhancements on a PHP Web app and,
timescales being what they are, I don't have enough time for "learn PHP in
21 days" or suchlike

Show Images Using A Start To End
i have a folder of images in numerical order.

45.jpg
46.jpg
47.jpg

in order for me to view them i have to type in the url and see if it exists. how am i able to make start to end of images. for example if i have a form with a start and end field of 40 - 50 how can they be displayed so i only see 40.jpg to 50.jpg PHP Code:

Installed PHP And Now Apache Won't Start
I installed Apache 2.2.3 per the instructions in the book I'm reading
'AJAX and PHP' by Darie et al. After installation, I confirmed that the
server was working. I then installed MySQL and PHP. After configuring
the system per the book's instructions, I now find that the Apache
server won't start.

How To Re-start A Program From Web Interface Using PHP
We are running a application on the Linux, and would like to have a web
interface to restart it remotely using PHP. I would like to get an
advice on how to do it.

Can’t Start A New Session Because “ The Headers Already Sent ”.
I am trying to make a session for a user login place on my page but when I try to do this it says that is can’t start a new session because “the headers already sent”. I guess I just don’t understand what counts as a “header”. Could someone please explain.


Copyright © 2005-08 www.BigResource.com, All rights reserved