PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Problem: What's an Illegal offset type? Posted by Neak on 3 Aug 2004 at 8:30 PM
Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135

Warning: implode(): Bad arguments. in /home/exirptco/public_html/gallery/mod.php on line 135

Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135

Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135

Warning: implode(): Bad arguments. in /home/exirptco/public_html/gallery/mod.php on line 135

Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135

There's my beautiful error.

I have no idea what the problem is, and I'm hoping it's more common a problem than it seems, and that someone will know how to fix it. For reference, here's the error line (135) and the surrounding 2 blocks of code.

	$NewStuff[0] = $_POST['title'];
	$NewStuff[1] = $_SESSION['handle'];
	$NewStuff[2] = $_POST['date'];
	$NewStuff[3] = $_POST['medium'];
	$NewStuff[4] = $_POST['comment'];
	
	$ImagePath = $_POST['path'];
			
	array_unshift($exploded, $NewStuff);
	
//---IMPLOSION---------------------------------------------------------------------------------
	$Fopened = fopen($Fooage, 'w');         		// Fopened file.
	$Freaded = fread($Fopened, filesize($Fooage));		// Fread File.
	
	// implode the parts, then implode them all together
	foreach ($exploded as $index)		// Go through each part of $exploded
	{
		$implodedFirst[$index] = implode("\r\n", $exploded[$index]);	// Implodes each part
										// depending on single new line.
	}
	$imploded = implode("\r\n\r\n", $implodedFirst);	// Implode by 2x new line...

	fputs($Fopened, $imploded);
	fclose($Fopened);
//---------------------------------------------------------------------------------------------
		
	// Image Uplosion
	ImgUpload($NewStuff[0], $NewStuff[1], $_FILES);	

Report
Re: Problem: What's an Illegal offset type? Posted by netgert on 4 Aug 2004 at 5:59 AM
:
Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135
: 
: Warning: implode(): Bad arguments. in /home/exirptco/public_html/gallery/mod.php on line 135
: 
: Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135
: 
: Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135
: 
: Warning: implode(): Bad arguments. in /home/exirptco/public_html/gallery/mod.php on line 135
: 
: Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 135

: There's my beautiful error.
:
: I have no idea what the problem is, and I'm hoping it's more common a problem than it seems, and that someone will know how to fix it. For reference, here's the error line (135) and the surrounding 2 blocks of code.
:
:
	$NewStuff[0] = $_POST['title'];
: 	$NewStuff[1] = $_SESSION['handle'];
: 	$NewStuff[2] = $_POST['date'];
: 	$NewStuff[3] = $_POST['medium'];
: 	$NewStuff[4] = $_POST['comment'];
: 	
: 	$ImagePath = $_POST['path'];
: 			
: 	array_unshift($exploded, $NewStuff);
: 	
: //---IMPLOSION---------------------------------------------------------------------------------
: 	$Fopened = fopen($Fooage, 'w');         		// Fopened file.
: 	$Freaded = fread($Fopened, filesize($Fooage));		// Fread File.
: 	
: 	// implode the parts, then implode them all together
: 	foreach ($exploded as $index)		// Go through each part of $exploded
: 	{
: 		$implodedFirst[$index] = implode("\r\n", $exploded[$index]);	// Implodes each part
: 										// depending on single new line.
: 	}
: 	$imploded = implode("\r\n\r\n", $implodedFirst);	// Implode by 2x new line...
: 
: 	fputs($Fopened, $imploded);
: 	fclose($Fopened);
: //---------------------------------------------------------------------------------------------
: 		
: 	// Image Uplosion
: 	ImgUpload($NewStuff[0], $NewStuff[1], $_FILES);	

:
$index is already an element from the array of $exploded, so use $index insead of that part
Also, find another solution for the $implodedFirst[$index] part, as $index probably isnt good for index, being a value of an array rather than index/key
You've misunderstood the foreach statement
the code might work when the foreach line would read (not tested):
foreach ($exploded => $index) // Go through each part

NetGert[/italic]


Report
Re: Problem: What's an Illegal offset type? Posted by Neak on 4 Aug 2004 at 5:19 PM
This message was edited by Neak at 2004-8-6 10:27:48

This message was edited by Neak at 2004-8-6 10:23:28

: $index is already an element from the array of $exploded, so use $index insead of that part
: Also, find another solution for the $implodedFirst[$index] part, as $index probably isnt good for index, being a value of an array rather than index/key
: You've misunderstood the foreach statement
: the code might work when the foreach line would read (not tested):
: foreach ($exploded => $index) // Go through each part
:
NetGert[/italic]

:
Bleh. Well, I thought I understood the foreach loop, because the code was copied and pasted from a different section of my site, which I wrote earlier (this code was the gallery section, copied from the news section.)
The only difference was the variable names. And, the news section code works fine. Here are both scripts for comparison.
Gallery Section (doesn't work):
	$NewStuff[0] = $_POST['title'];
 	$NewStuff[1] = $_SESSION['handle'];
 	$NewStuff[2] = $_POST['date'];
 	$NewStuff[3] = $_POST['medium'];
 	$NewStuff[4] = $_POST['comment'];
 	
 	$ImagePath = $_POST['path'];
 			
 	array_unshift($exploded, $NewStuff);
 	
 //---IMPLOSION---------------------------------------------------------------------------------
 	$Fopened = fopen($Fooage, 'w');         		// Fopened file.
 	$Freaded = fread($Fopened, filesize($Fooage));		// Fread File.
 	
 	// implode the parts, then implode them all together
 	foreach ($exploded as $index)		// Go through each part of $exploded
 	{
 		$implodedFirst[$index] = implode("\r\n", $exploded[$index]);	// Implodes each part
 										// depending on single new line.
 	}
 	$imploded = implode("\r\n\r\n", $implodedFirst);	// Implode by 2x new line...
 
 	fputs($Fopened, $imploded);
 	fclose($Fopened);
 //---------------------------------------------------------------------------------------------
 		
 	// Image Uplosion
 	ImgUpload($NewStuff[0], $NewStuff[1], $_FILES);	

News Section (does work):
	$NewStuff[0] = $_POST['title'];
	$NewStuff[1] = $_SESSION['handle'];
	$NewStuff[2] = $_POST['date'];
	$NewStuff[3] = $_POST['content'];

	array_unshift($exploded, $NewStuff);

//---IMPLOSION---------------------------------------------------------------------------------
	$Fopened = fopen($Fooage, 'w');         		// Fopened file.
	$Freaded = fread($Fopened, filesize($Fooage));	// Fread File.

	// implode the parts, then implode them all together
	foreach ($exploded as $index)		// Go through each part of $exploded
	{
		$implodedFirst[$index] = implode("\r\n", $exploded[$index]); // Implodes each part
				                                  	     // depending on single new line.
	}
	$imploded = implode("\r\n\r\n", $implodedFirst);	// Implode by 2x new line...

	fputs($Fopened, $imploded);
	fclose($Fopened);
//---------------------------------------------------------------------------------------------


Does anyone know why one code would work when it's practically identical to the code that doesn't?


Report
Re: Problem: What's an Illegal offset type? Posted by Neak on 7 Aug 2004 at 8:59 PM
: The only difference was the variable names. And, the news section code works fine. Here are both scripts for comparison.
: Gallery Section (doesn't work):
:
	$NewStuff[0] = $_POST['title'];
:  	$NewStuff[1] = $_SESSION['handle'];
:  	$NewStuff[2] = $_POST['date'];
:  	$NewStuff[3] = $_POST['medium'];
:  	$NewStuff[4] = $_POST['comment'];
:  	
:  	$ImagePath = $_POST['path'];
:  			
:  	array_unshift($exploded, $NewStuff);
:  	
:  //---IMPLOSION---------------------------------------------------------------------------------
:  	$Fopened = fopen($Fooage, 'w');         		// Fopened file.
:  	$Freaded = fread($Fopened, filesize($Fooage));		// Fread File.
:  	
:  	// implode the parts, then implode them all together
:  	foreach ($exploded as $index)		// Go through each part of $exploded
:  	{
:  		$implodedFirst[$index] = implode("\r\n", $exploded[$index]);	// Implodes each part
:  										// depending on single new line.
:  	}
:  	$imploded = implode("\r\n\r\n", $implodedFirst);	// Implode by 2x new line...
:  
:  	fputs($Fopened, $imploded);
:  	fclose($Fopened);
:  //---------------------------------------------------------------------------------------------
:  		
:  	// Image Uplosion
:  	ImgUpload($NewStuff[0], $NewStuff[1], $_FILES);	

: News Section (does work):
:
	$NewStuff[0] = $_POST['title'];
: 	$NewStuff[1] = $_SESSION['handle'];
: 	$NewStuff[2] = $_POST['date'];
: 	$NewStuff[3] = $_POST['content'];
: 
: 	array_unshift($exploded, $NewStuff);
: 
: //---IMPLOSION---------------------------------------------------------------------------------
: 	$Fopened = fopen($Fooage, 'w');         		// Fopened file.
: 	$Freaded = fread($Fopened, filesize($Fooage));	// Fread File.
: 
: 	// implode the parts, then implode them all together
: 	foreach ($exploded as $index)		// Go through each part of $exploded
: 	{
: 		$implodedFirst[$index] = implode("\r\n", $exploded[$index]); // Implodes each part
: 				                                  	     // depending on single new line.
: 	}
: 	$imploded = implode("\r\n\r\n", $implodedFirst);	// Implode by 2x new line...
: 
: 	fputs($Fopened, $imploded);
: 	fclose($Fopened);
: //---------------------------------------------------------------------------------------------

:
: Does anyone know why one code would work when it's practically identical to the code that doesn't?

Anybody?
Report
Interesting... Posted by Neak on 12 Aug 2004 at 7:22 PM
Wow. Well, I've gone through two of my files: the file for modifying news content on my website and the file for modifying image gallery content.

I made the news section of the site first, as it's the openning page. It works.

Then, I copied and pasted the code and changed parts for the gallery section. It should work, I only changed a few things, mostly just adding an image uploading function and random thumbnail generator.

I use Vim text editor, so I can open two files in one window to compare them. I've gone through the loops, line by line, comparing the two files. I've replaced code from the gallery section with code from the news section to try and find where the error is coming from. To no avail. No matter what I do, the same error occurs:
Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 134

Warning: implode(): Bad arguments. in /home/exirptco/public_html/gallery/mod.php on line 134

Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 134

Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 134

Warning: implode(): Bad arguments. in /home/exirptco/public_html/gallery/mod.php on line 134

Warning: Illegal offset type in /home/exirptco/public_html/gallery/mod.php on line 134


I've been working on this for so long and I truly can not find a solution. I'm thinking that maybe someone here, if anyone has the time, could look at the files and tell me if they know the problem. Here are links to the two files in a .txt format.

http://www.exirpt.com/help/news_mod.txt News Script
http://www.exirpt.com/help/gallery_mod.txt Gallery Script

If anyone could help me it would be greatly appreciated.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.