Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

same URL var array?

Status
Not open for further replies.

Niv3k

Programmer
Jul 11, 2001
350
US
I want to pass an array of values through as variables, and in ASP I know you can do it.
Code:
[URL unfurl="true"]http://localhost/array.php?id=nivek&id=cooldude&id=boborstuff[/URL]
But when I try an equivelant in php:
Code:
<?php
$Counter = 0; 
while ($id[$Counter]) {
	echo $id[$Counter].&quot; &quot;;
	$Counter++;
}
?>
I get:
Code:
b o b o r s t u f f 
Warning: Uninitialized string offset: 10 in c:\inetpub\[URL unfurl="true"]wwwroot\array.php[/URL] on line 7
when I want to get nivek cooldude boborstuff

Any idears?

Kevin
 
okay, I found part of the answer... if I change the URL to id[]=nivek&id[]=whatever then the array works...

But I still get the Uninitialized string offset error...

Kevin
 
and I got the offset error by using isset():
Code:
while (isset($id[$Counter])) {
	echo $id[$Counter].&quot; &quot;;
	$Counter++;
}
 
go to the PHP.INI and check for error_reporting.

put this there:
error_reporting = E_ALL & ~E_NOTICE

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top