R0bb0b 344 Posting Shark

I've never used that script but it sounds like this type of error:
I don't see <div>s that match up to these two lines:

Rounded("div#second","#EFF6F9","#9BD1FA"); 
Rounded("div#third","#EFF6F9","#9BD1FA");

:-/

R0bb0b 344 Posting Shark

This explains many options for submit buttons
http://www.cs.tut.fi/~jkorpela/forms/imagebutton.html

R0bb0b 344 Posting Shark

No problem :)

R0bb0b 344 Posting Shark

That's wierd :-/

R0bb0b 344 Posting Shark

So you have to pass it an array? you can't just grab a global one?

You have to declare it as global in the function, view the last function in the class

<?
$globalTestArray = array('Hello', ' ', 'World', '2');
$objtest = new Test(array('Hello', ' ', 'World'));
$objtest->echoArrayA1();
$objtest->echoArrayA2();

class Test
{
	var $TestArray = array();
	
	function Test($inputArray)
	{
		$this->setTestArray($inputArray);
		$this->Display();
		$this->echoGlobalTestArray();
	}
	
	function Display()
	{
		foreach($this->TestArray as $value)
		{
			echo $value;
		}
	}
	
	function setTestArray($inputArray)
	{
		if(is_array($inputArray))
		{
			$this->TestArray = $inputArray;
		}
	}
	
	function echoArrayA1()
	{
		$a = array('a');
		foreach($a as $value)
		{
			echo "<br />" . $value;
		}
	}
	
	function echoArrayA2()
	{
		$a[0] = 'b';
		foreach($a as $value)
		{
			echo "<br />" . $value;
		}
	}
	
	function echoGlobalTestArray()
	{
		global $globalTestArray;
		echo "<br />";
		foreach($globalTestArray as $value)
		{
			echo $value;
		}
		echo "<br />";
	}
}
?>
percent20 commented: This helped me to figure out the answer +4
R0bb0b 344 Posting Shark
<?
$objtest = new Test(array('Hello', ' ', 'World'));
$objtest->echoArrayA1();
$objtest->echoArrayA2();

class Test
{
	var $TestArray = array();
	
	function Test($inputArray)
	{
		$this->setTestArray($inputArray);
		$this->Display();
	}
	
	function Display()
	{
		foreach($this->TestArray as $value)
		{
			echo $value;
		}
	}
	
	function setTestArray($inputArray)
	{
		if(is_array($inputArray))
		{
			$this->TestArray = $inputArray;
		}
	}
	
	function echoArrayA1()
	{
		$a = array('a');
		foreach($a as $value)
		{
			echo "<br />" . $value;
		}
	}
	
	function echoArrayA2()
	{
		$a[0] = 'b';
		foreach($a as $value)
		{
			echo "<br />" . $value;
		}
	}
}
?>

Any Questions?

R0bb0b 344 Posting Shark

So the .csv file is an exact replica of the .txt file?

R0bb0b 344 Posting Shark

Still just empty rows?

R0bb0b 344 Posting Shark

If you post a new thread, I will certainly look at it.

R0bb0b 344 Posting Shark

I would say you probably want to do something like this:

select min(visit_date), recordid, fname, lname from artist_details inner join attendance using(recordid) where visit_date < '2008-06-25' and visit_date > '2008-06-23' group by recordid,  fname, lname
R0bb0b 344 Posting Shark

I really don't think it has anything to do with the file size at all. I know I'm not an admin but I've imported Gig dump files into bran new mysql databases before and never heard about any type of file size limitation before.

R0bb0b 344 Posting Shark

Hmm. The only way that I know to be sure is to look at the sql, and that's a lot of sql. Another option would be to break the file into parts and upload them one at a time to help to isolate the problem.

R0bb0b 344 Posting Shark

OK, so the script works. I think it has something to do with the syntax within the file, let's debug.

replace line 225:

$qry = mysql_query($query,$conn);

with

$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));

then run again and post your output.

maydhyam commented: Great Job.....Thanks :) +1
R0bb0b 344 Posting Shark

Umm.. Just curious, how are you joining those 2 tables ? On what condition ?
If there is no condition for join, wouldn't it give the cartesian product of 2 tables ?
That is, first, it will select all the records from artists_details where ethnicity is 'maori'. Then, it will select the records from attendance table where visit_date >= June 1st and visit_date <= June 19th. :-/

Good eye! I believe you are right.

R0bb0b 344 Posting Shark

You make a little mistake I think, the code you are showing must be, I

Actually it does exactly what I was thinking:
27:30
(30 + (27 * 60)) / 5 = 330 minutes

kvdd commented: He helped me kindfull +1
R0bb0b 344 Posting Shark

SELECT * FROM artists_details JOIN attendance WHERE artists_details.ethnicity='maori' AND attendance.date >= '2008-06-01' AND attendance.date <= '2008-06-20'

try

SELECT DISTINCT * FROM artists_details JOIN attendance WHERE artists_details.ethnicity='maori' AND attendance.date >= '2008-06-01' AND attendance.date <= '2008-06-20'
R0bb0b 344 Posting Shark
$this->hash->add($entry['key'], $entry['value']);

try getting rid of
this-> on line 39
so all you have is

$hash->add($entry['key'], $entry['value']);

and getting rid of $this-> on line 54

R0bb0b 344 Posting Shark

Like this?

list($hrs, $mins) = explode(":", $time);
$mins += $hrs * 60;
$endresult = $mins/5;
echo $endresult;
R0bb0b 344 Posting Shark

As many studies in OOP as I had through school and even after school, didn't really do me any good either. It wasn't until about 2 yrs into my career that I actually learned the value of inheritance and function overriding. So I would say, don't worry, it will come to you.

One good example would be if you have an application that you will need to update in the future, you don't want to actually modify the code in the application itself because once you run the next update, whatever modifications you have made would now be broken. Rather you would want to make classes that extend classes in said application so when the application is updated, your code doesn't break but may have to be modified a little.

rickya100 commented: Very helpful +1
R0bb0b 344 Posting Shark

I've never seen it done that way and actually its not done to reference the parenting function but rather $this refers to the parenting class. Here's how it works.

If you know a little about OOP then you should get this.

class One
{
	var $classonevar = "";
	function __construct() //constructor, can also be called function One() for previous PHP versions
	{
		
	}
	
	function setClassOneVar($input)
	{
		$this->classonevar = $input;
		$this->classtwovar = $input; //doesn't work because it is out of scope
	}
}

class Two extends One
{
	var $classtwovar = "";
	function __construct() //constructor, can also be called function Two() for previous PHP versions
	{
		
	}
	
	function setClassOneVar($input) //overrides One.setClassOneVar
	{
		$result = parent::setClassOneVar("dog"); //calls the setClassOneVar in class One
		
		//$result can then be manipulated here and returned from here
		
		$this->classonevar = $input; //also manipulates $classonevar because this class extends that class
		$this->classtwovar = $input; //manipulates $classtwovar in this class
	}
	
	function setClassTwoVar($input)
	{
		$this->classtwovar = $input; //manipulates $classtwovar in this class
	}
}

$obj1 = new One();
$obj1->//any function or public variable in class One
$obj2 = new Two();
$obj2->//any function or public/protected variable in class Two or One
rickya100 commented: Great help. Explanations and code. Appreciate it. +1
R0bb0b 344 Posting Shark

sets keys to values in an array ex.

$array = array("mydog"->"spot", "yourdog"->"rover");

it is also used in this syntax

$object->function();

or

$object->variable = $variable;

where "function()" would be a function in the instantiated object
and "variable" would be a variable in the instantiated object.
I'm not exactly sure what that is that you have listed there though, if you took out the second "$" it would make sense.

R0bb0b 344 Posting Shark

try this

CONCAT( UPPER( SUBSTRING( colname, 1, 1 ) ) , LOWER( SUBSTRING( colname, 2 ) ) )
R0bb0b 344 Posting Shark

right, because you are submitting it as an array and trying to enter it directly in the db that way.

When you say

$array = array("val1", "val2");
echo $array;

Your output will be just "array".

The following will process the array and create a comma separated list of selected values.

$vccategory = "";
foreach($_POST['vccategory'] as $value)
{
	$vccategory .= $value . ", ";
}
$vccategory = substr($vccategory, 0, -2); //to get rid of the final ", "
R0bb0b 344 Posting Shark

I tried it myself and the javascript works fine for me in IE and FF. Your talking about the date and time up in the top right I assume, yeah it works for me just fine.

maydhyam commented: Great Help....Thank you again...:) +1
R0bb0b 344 Posting Shark

This would be easier if you could see a real error. I'm pretty sure it has to do with that resizing function, possible the paths going in, I don't know.

If your configuration file is set to block errors from being displayed you could put the following two lines at the top of the script and see if that makes a difference.

ini_set("display_errors", "1");
error_reporting (E_ALL);
R0bb0b 344 Posting Shark

It simply displays Image cannot be uploaded message after I try to upload image.

Is that a custom error or a php error?

R0bb0b 344 Posting Shark

Yes. The form and script is on the same file. You should be able to just copy and past it to a file and watch it work. Right now it just echos the contents of the file to the page and all you need to do is plug that variable into a db query.

R0bb0b 344 Posting Shark

If you know the contents of the file is valid and there is no risk then this works fine up until the mysql_query part as that will depend on your query and table structure.

<?
ini_set("display_errors", "1");
error_reporting (E_ALL);

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'];
		$fh = fopen($_FILES['file']['tmp_name'], 'r');
		$handle = fopen($filename, "r");
		$contents = fread($handle, filesize($filename));
		fclose($handle);
		
		echo $contents;
                //db conn stuff
                //mysql_query($contents);
	}
	else
	{
		echo "invalid format";
	}
}
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="<? echo $_SERVER['REQUEST_URI']; ?>" enctype="multipart/form-data" method="post">
	<input type="file" name="file" /><input type="submit" value="Submit" name="btnSubmit" />
</form>
</body>
</html>
R0bb0b 344 Posting Shark

I don't know if it will throw an error but you don't need $this-> if you are not in object context.
Another thing, I don't know if you did already but you may want to check the permissions of that dir you are trying to upload to.

What is the error?

This seems to be well tested.
http://mediumexposure.com/techblog/smart-image-resizing-while-preserving-transparency-php-and-gd-library

R0bb0b 344 Posting Shark

When I say echo all of the variables, I mean rather than writing ifs and elses when I writing PHP, I usually start simple first.

Upon uploading the document I would do a print_r($_FILES);

This will show you everything that is in the array including the filetype, and that is where I would go from where you are now and build my php around that.

R0bb0b 344 Posting Shark

see the following line at
http://blog.mikeseth.com/index.php?/archives/2-How-not-to-get-hacked-uploaded-files-in-PHP.html
"File's MIME type (derived from the Content-Type header) is an appealing factor, but you should not do any checks on it. It can be faked by the uploader, so you can't trust its contents."

This is $_FILES and it can be faked.
I always go by the extention:
$ext = substr(trim($filenamestring), -3);
this will give you the extension of the file.

You also need to consider the content of the file, even if it is sql, results can be unpredictable if you don't validate it somehow. I've never needed to look for an open source sql validator, so I'm not exactly sure if one exists, but I would assume that someone has already made one. If you don't find one you can use the function file() and require from your user that each sql command is one one line, or something of that sort. And then validate it on your own. I'm just saying that nobody is putting anything in my database if I don't know what it is first.

R0bb0b 344 Posting Shark

two things:
First: $_FILES comes from the browser which is not reliable.

I would take the content of the file and then validate it against an open source php sql validator.

if that comes back false then reply back to the user that the syntax is not correct.

Second: I would echo all of the variables back to you including the filetype so you can see what you are dealing with here.