R0bb0b 344 Posting Shark

According to the documentation of that date picker, that should work. Are you sure that nothing is modifying $sDate and $eDate prior to your query. What you may want to do is this. Change the action on your form to post to another file and in that file just put this.

<?
echo "SELECT * FROM tsttbills where DATE_FORMAT(billDate, '%e-%m-%Y') >= '" . $_POST['sDate'] . "' and DATE_FORMAT(billDate, '%e-%m-%Y') <= '" . $_POST['eDate'] . "'";
?>

This way we can eliminate the date picker as the issue.

R0bb0b 344 Posting Shark

did you update your html form inputs and js calendars to be like this?

<input id="demo1" type="text" size="25"><a href="javascript:NewCal('demo1','mmddyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
R0bb0b 344 Posting Shark

Step 1. Place both thumbs at center of cd while positioning index and middle fingers from both hands firmly around the cd on each side.

Step 2. Now slowly apply pressure to both thumbs. It is normal to hear crackling noises so don't be alarmed.

repeat step 2 until desired satisfaction level is reached.

R0bb0b 344 Posting Shark

test data

-- 
-- Table structure for table 'tsttbills'
-- 

CREATE TABLE tsttbills (
  tsttbillspk int(11) NOT NULL auto_increment,
  billname varchar(60) default NULL,
  billphone varchar(12) default NULL,
  billDate date default NULL,
  PRIMARY KEY  (tsttbillspk)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

-- 
-- Dumping data for table 'tsttbills'
-- 

INSERT INTO tsttbills VALUES (1, 'billy', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (2, 'steven', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (3, 'robert', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (4, 'nickie', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (5, 'robbie', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (6, 'malahni', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (7, 'bo', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (8, 'bill', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (9, 'steve', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (10, 'I', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (11, 'they', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (12, 'them', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (13, 'you', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (14, 'me', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (15, 'ed', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (16, 'joe', '9895475487', '2007-01-11');
INSERT INTO tsttbills VALUES (17, 'bill', '9895475487', '2007-12-06');
INSERT INTO tsttbills VALUES (18, 'bob', '9895475487', '2007-01-11');
SELECT *
FROM tsttbills
WHERE DATE_FORMAT( billDate, '%c-%d-%Y' ) >= '1-11-2007' AND DATE_FORMAT( billDate, '%c-%d-%Y' ) <= '1-11-2007';

'%c-%d-%Y' works for 'm-dd-yyyy'
brought back 9 rows

SELECT * FROM tsttbills where DATE_FORMAT(billDate, '%e-%m-%Y') >= '1-11-2007' and DATE_FORMAT(billDate, '%e-%m-%Y') <= '1-11-2007'

'%e-%m-%Y' works for 'dd-mm-yyyy' brought back 0 rows because this is the wrong format

you need to study …

R0bb0b 344 Posting Shark

replace echo $sql;
with echo $query;

R0bb0b 344 Posting Shark

I'm pretty sure that ‘ ’ are not valid quote characters in php
so changed ‘HTTP_USER_AGENT’
to 'HTTP_USER_AGENT'

if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "google") === FALSE)
R0bb0b 344 Posting Shark
R0bb0b 344 Posting Shark

I am still getting the entire table of data, and the data within the dates selected...

The only way we can know for sure is if you echo your query statement at runtime. So rather than running the query with mysql_query(), just echo it. Then post that.

R0bb0b 344 Posting Shark

You could do it on any file since you are accessing the same database either way. However, you need to know what columns and data types to assign to the table. Did you get a .sql file or a readme.txt file with the package that might give you this info?

R0bb0b 344 Posting Shark

sorry, sometimes my words don't come out right.

R0bb0b 344 Posting Shark

No you don't have to change anything but your query. Here is the function documentation with all of the date format symbols. The calendar function just needs to be consistent.
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

R0bb0b 344 Posting Shark

the dates i entered for the search were: 1-11-2007 and 9-11-2007

these days don't have leading zeros, so your query will actually look like this

"SELECT * FROM tsttbills where DATE_FORMAT(billDate, '%e-%m-%Y') >= '$sDate' and DATE_FORMAT(billDate, '%e-%m-%Y') <= '$eDate'"

instead of this:

"SELECT * FROM tsttbills where DATE_FORMAT(billDate, '%d-%m-%Y') >= '$sDate' and DATE_FORMAT(billDate, '%d-%m-%Y') <= '$eDate'"

R0bb0b 344 Posting Shark

put this right under your mysql_query()

echo "SELECT * FROM tsttbills where DATE_FORMAT(billDate, '%d-%m-%Y') >= '$sDate' and DATE_FORMAT(billDate, '%d-%m-%Y') <= '$eDate'";

so we can get a look at your query including the variables.

R0bb0b 344 Posting Shark

OK, this should do it now:

gcrFunction.php

<?
include('./connect.php');

error_reporting(E_ALL ^ E_NOTICE);

function validateData()
{
	global $conn;
	
	$sDate=$_POST['sDate'];
	$eDate=$_POST['eDate'];
	//echo $sDate;
	//echo $eDate;

	$btn=$_POST['btnSubmit'];
		
	if(isset($btn))
	{				
		if(!$sDate)
		{
			echo '<center><font face=Verdana color=Red size="2"><b>Start Date field is empty!</b></font></center></td>
				  </tr><tr bgcolor="#ffffff"><td>
				  <table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFf">
				  <tr><td width="760" bgcolor="#336666" scope="col">&nbsp;</td></tr></table></td></tr><tr bgcolor="#ffffFF">
				  <td><p align="center" class="style30 style4" >&copy;ITT Department, Petrotrin. </p></td></tr></table>';
			die("Problem 1");
		}
		else if(!$eDate)
		{
			echo '<center><font face=Verdana color=Red size="2"><b>End Date field is empty!</b></font></center></td>
				  </tr><tr bgcolor="#ffffff"><td>
				  <table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFf">
				  <tr><td width="760" bgcolor="#336666" scope="col">&nbsp;</td></tr></table></td></tr><tr bgcolor="#ffffFF">
				  <td><p align="center" class="style30 style4" >&copy;ITT Department, Petrotrin. </p></td></tr></table>';
			die("Problem 2");
		}
		else
		{
			
			function parseCSVComments($comments) 
			{ 
				// First off escape all " and make them "" 
				$comments = str_replace('"', '""', $comments); 
				if(eregi(",", $comments) or eregi("\n", $comments)) 
				{ // Check if I have any commas or new lines 
				return '"'.$comments.'"'; // If I have new lines or commas escape them 
				} 
				else 
				{ 
					return $comments; // If no new lines or commas just return the value 
				} 
			} 
			
			// Start our query of the database 
			$query = "SELECT * FROM tsttbills where DATE_FORMAT(date, '%d-%m-%Y') >= '$sDate' and DATE_FORMAT(date, '%d-%m-%Y') <= '$eDate'";
			$sql = mysql_query($query, $conn);
			 
			//echo $query;
			$numberFields = mysql_num_fields($sql); // Find out how many fields we are fetching 
			
			if($numberFields) 
			{ // Check if we need to output anything 
				for($i=0; $i<$numberFields; $i++) 
				{ 
					// Create the headers for each column, this is the field name in the database 
					$head[] = mysql_field_name($sql, $i); 
				} 
				$headers = join(',', $head)."\n"; // Make our first row …
R0bb0b 344 Posting Shark

OK, so post your code one more time so I can get a feel of where we are.

R0bb0b 344 Posting Shark

echo you query and run it in your mysql manager and see if that pulls data, that way you can eliminate that as an issue.

R0bb0b 344 Posting Shark

ive found ur mistake. ur using
the following,

$name = $_POST['first']; 
$query = "SELECT * FROM runners WHERE id =".$name;

do this,

$name = $_POST['first']; 
$query = "SELECT * FROM runners WHERE first_name =".$name;

u are using the wrong field. u are comparing an int field with string and ur are comparing the id field with the name.

mysql is still going to parse the name as a column because of the lack of single quotes

R0bb0b 344 Posting Shark

This is what I got:

SELECT * FROM runners WHERE id =JustinUnknown column 'Justin' in 'where clause'

I only have 1 column of data in the database. Justin is the first name.

mysql is considering justin a column because you are not single quoting it. if id is suppose to be numeric then can process it without single quotes but I do it anyway for security purposes.

R0bb0b 344 Posting Shark

right under this line $query = "SELECT * FROM runners WHERE id = '$name'"; put echo $query; run it, copy the results, and post it.

R0bb0b 344 Posting Shark

Just relieved to see that the data is consistent. You never really know with a varchar since there really is no structure to keep it in the correct format, you could have had a lot of work ahead of you.

R0bb0b 344 Posting Shark

echo your query and post it.

R0bb0b 344 Posting Shark

put in more die functions.

<?php
	// Include connection to your database
	$con = mysql_connect("localhost","root","") or die(mysql_error());;
	mysql_select_db("RUNNERS", $con) or die(mysql_error());
	
	$name = $_POST['first']; 
	$query = "SELECT * FROM runners WHERE id =".$name;
	$result = mysql_query($query) or die(mysql_error());?>

<table class="sortable">
	<!-- Table Header -->
	<thead>
	<tr>
	<th>ID #</th>
	<th>First Name</th>
	<th>Last Name</th>
	<th>1 Mile</th>
	<th>2 Mile</th>
	<th>5k</th>
	<th>8k</th>
	<th>10k</th>
	<th>20k</th>
	<th>13.1</th>
	<th>26.2</th>
	</tr>
	</thead>

<!-- Table body-->
	<tbody>
	<?php while ($list = mysql_fetch_assoc($result)) ?>
	<tr>
	<th><?php echo $list['first_name'] ?></th>
	<th><?php echo $list['last_name'] ?></th>
	<th><?php echo $list['one'] ?></th>
	<th><?php echo $list['two'] ?></th>
	<th><?php echo $list['five'] ?></th>
	<th><?php echo $list['ten'] ?></th>
	<th><?php echo $list['fifteen'] ?></th>
	<th><?php echo $list['twenty'] ?></th>
	<th><?php echo $list['half'] ?></th>
	<th><?php echo $list['full'] ?></th>
	</tr>
	</tbody>


</table>

I agree with Shanti, there is something wrong with your query and this should tell you what it is.

R0bb0b 344 Posting Shark

OK, javascript is client side = must be parsed by the web browser.

So this means that the possibility of php parsing the javascript and running it is out of the realm of possibility, so you need a work around.

How about this, in your php script, if the google maps data is non existent, redirect to the page with the google maps javascript, then redirect back to the php script with the data either in the url or in a session variable.
:-/

R0bb0b 344 Posting Shark

That happens when you send anything to the browser before trying to redirect, even a blank line. So if your "<?php" starts on line 2, you will get an error if you try to redirect at any point in the script.

As far as the images still being there, the redirect probably will solve the problem because I think it is browser cache. You say the images aren't in the directory anymore but they still appear on the page right? ya browser cache. Try to get the redirect to work. If you can't get it to work, post your entire script because according to that error, you sent headers prior to the redirect, which means that you are not including something above this block of script, right?

R0bb0b 344 Posting Shark

I have a javascript that looks up some details on googlemaps for me, then returns them to a php script

I don't understand why you don't just do this with Curl, then you could run the entire script from cron or from another php file or whatever you want.

R0bb0b 344 Posting Shark

:sweat: :sweat: :sweat: :sweat: :sweat: :sweat:
cool

peter_budo commented: Nice done job +9
R0bb0b 344 Posting Shark

You should be able to do it one of two ways:


Number 1: (adjust '%d/%m/%Y' to match up to the format that is on the csv, it is currently looking for "dd/mm/yyyy")

if(count($_FILES) > 0)			
			{					
				$ext = "";				
				$ext = substr(trim($_FILES["file"]["name"]), -4);				
				$allowedext = array(".txt", ".csv", ".sql"); 				
				
				if(in_array($ext, $allowedext))				
				{					
					$filename = $_FILES['file']['tmp_name'];				
					$handle = fopen($filename, "r"); 			
					
					while (($data = fgetcsv($handle, 100000, ',', '"')) !== FALSE)					
					{
						//print_r($data);
						//echo("<br />"); 
						$value1 = $data[0];
						$value2 = $data[1];
						$value3 = $data[2];
						$value4 = $data[3];
						$value5 = $data[4];
						$value6 = $data[5];
						$value7 = $data[6]; 
						$value8 = $data[7]; 
						$value9 = $data[8];
						$value10 = $data[9]; 
						$value11 = $data[10]; 
						$value12 = $data[11]; 
						//echo("<br />"); 
										
						$query = "INSERT INTO testtsttbills (account,service,billDate,time,timebandtype,destination,callednumber,mins,airtimecharge,tollcharge,amt,privatenumber) VALUES ('$value1','$value2',STR_TO_DATE('$value3', '%d/%m/%Y'),'$value4','$value5','$value6','$value7','$value8','$value9','$value10','$value11','$value12')";						
						
						$qry = mysql_query($query,$conn) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno($conn) . ") " . mysql_error($conn));
											
					}				
					fclose($handle);				
					echo "<div align='center'><font color='red'>The file was uploaded.</font></div>";				
				}				
				else				
				{					
					echo "<div align='center'><font color='red'>You are trying to upload an invalid file format. Please try again.</font></div>";		
				}			
			}

Number 2: (adjust list($dy, $mo, $yr) to match up to the format that is on the csv, it is currently looking for "dd/mm/yyyy")

if(count($_FILES) > 0)			
			{					
				$ext = "";				
				$ext = substr(trim($_FILES["file"]["name"]), -4);				
				$allowedext = array(".txt", ".csv", ".sql"); 				
				
				if(in_array($ext, $allowedext))				
				{					
					$filename = $_FILES['file']['tmp_name'];				
					$handle = fopen($filename, "r"); 			
					
					while (($data = fgetcsv($handle, 100000, ',', '"')) !== FALSE)					
					{
						//print_r($data);
						//echo("<br />"); 
						$value1 = $data[0];
						$value2 = $data[1];
						list($dy, $mo, $yr) = explode("/", $data[2]);
						$value3 = …
R0bb0b 344 Posting Shark

I guess we go with option B then. Delete data and import your csv. The date column should be like this, STR_TO_DATE('13/09/2007', '%d/%m/%Y') .

R0bb0b 344 Posting Shark

I believe so, since there is no result set to return. Now do a desc tsttbills; and confirm that the column is now a date field and kind of scan through a sample of the data to verify that the data is still intact and that none of the billdates were truncated or altered in any way besides the format change to 'yyyy-mm-dd'.

R0bb0b 344 Posting Shark

That's strange because its just an http request as far as the server goes. It should just serve the html like normal. This doesn't make any sense to me, maybe someone else can give you more input.

R0bb0b 344 Posting Shark

post your code on from thumbloader.php

R0bb0b 344 Posting Shark

"incorrect datetime value '13/09/2007' for function str_to_time"
Is "13/09/2007" the value in the billdate field, that looks like "dd/mm/yyyy" not "mm/dd/yyyy". If that is the value in the billdate column, I think this will work:

update tsttbills set billdate = STR_TO_DATE(billdate, '%d/%m/%Y');
ALTER TABLE tsttbills CHANGE `billdate` `billdate` date;
R0bb0b 344 Posting Shark

try it now

oh good, ok

I do get a few javascript errors but they don't stop it from working though.

R0bb0b 344 Posting Shark

The script that I posted for you works fine for me, you can see it here.
http://dev.ositnet.com/test.php

R0bb0b 344 Posting Shark

i have attached the editor which i have with this reply.i was not able to find the below files in the editor which i have

example_data/example_link_list.js,
	external_image_list_url : "example_data/example_image_list.js",
	flash_external_list_url : "example_data/example_flash_list.js"});
</script

Think it is suppose to be

lists/link_list.js,
	external_image_list_url : "lists/image_list.js",
	flash_external_list_url : "lists/flash_list.js"});
</script
R0bb0b 344 Posting Shark

That was funny, I responded to your post and mine is stacked on top.

R0bb0b 344 Posting Shark

That's a good sign.

R0bb0b 344 Posting Shark

I changed the name of the field in my table from 'date' to 'billDate'

so should it be:

update tsttbills set billDate = STR_TO_DATE(billDate, '%m/%d/%Y');

ALTER TABLE tsttbills CHANGE `billDate` `billDate` date;

???

you have the table backed up, right? Then yes.

R0bb0b 344 Posting Shark

Try this first:

update tsttbills set date = STR_TO_DATE(date, '%m/%d/%Y');
ALTER TABLE tsttbills CHANGE `date` `date` date;

Any questions or Concerns?

R0bb0b 344 Posting Shark

doing research on date data type functions. So hold on.

R0bb0b 344 Posting Shark

if the data in it matches the datatype then yes, otherwise you may get an error. I would say, make sure you back up the table first, then try it.

R0bb0b 344 Posting Shark

If you have just test data in the table you should probably do a "delete from tsttbills;" and then run "ALTER TABLE tsttbills CHANGE `date` `date` date;"

and personally, I would change the column name to something similar like tstdate, in that case you would run "ALTER TABLE tsttbills CHANGE `date` `tstdate` date;".

FYI: the reason that we are doing this is that mysql doesn't do date calculation with a text field like a varchar, as far as I know anyway.

R0bb0b 344 Posting Shark

Oh, date is a varchar, you need to change the date data type to "date". Here is a reference:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html

R0bb0b 344 Posting Shark

Run this query in your database manager and post your results:

desc tsttbills;
R0bb0b 344 Posting Shark

i got only a text area ...........

is this line referencing the correct location?

<script language="javascript" type="text/javascript" src="js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
R0bb0b 344 Posting Shark

OK, post your table create statement.

R0bb0b 344 Posting Shark
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript" src="js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
	// General options
	mode : "textareas",
	theme : "advanced",
	plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

	// Theme options
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true,

	// Example content CSS (should be your site CSS)
	content_css : "css/content.css",

	// Drop lists for link/image/media/template dialogs
	template_external_list_url : "lists/template_list.js",
	external_link_list_url : "lists/link_list.js",
	external_image_list_url : "lists/image_list.js",
	media_external_list_url : "lists/media_list.js",

	// Replace values for the template plugin
	template_replace_values : {
		username : "Some User",
		staffid : "991234"
	}
});

</script>
</head>

<body>
<textarea cols="80" rows="15"></textarea>
</body>
</html>
R0bb0b 344 Posting Shark

How did it go?

R0bb0b 344 Posting Shark

click on this link: http://prdownloads.sourceforge.net/tinymce/tinymce_3_1_0_1.zip?download

In it you will find a folder called "tinymce". If you look in it you will find two folders, "examples" and "jscripts" and a file called "changelog.txt". The only folder that is important is the "jscripts" folder so you can remove the other two items if you want. What you want to do is upload the whole "tinymce" folder to your ftp site where ever you want, I keep mine in my js folder. You will find the best examples here: http://wiki.moxiecode.com/examples/tinymce/installation_example_00.php and you can navigate between examples on the top right drop down. Here is the advanced example http://wiki.moxiecode.com/examples/tinymce/installation_example_02.php

Let me know if you have any troubles or questions, I'll help you as best I can.

R0bb0b 344 Posting Shark

try this:

$sql = mysql_query("SELECT * FROM tsttbills where DATE_FORMAT(date, '%d-%m-%Y') >= '$sDate' and DATE_FORMAT(date, '%d-%m-%Y') <= '$eDate'", $conn);

just edited this to replace the "/" with "-"