Passing an array with URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fari
Forum Commoner
Posts: 42
Joined: Thu Sep 19, 2002 8:41 pm
Location: Timmins - Ontario

Passing an array with URL

Post by Fari »

Hi guys - my next dilemma:

this script gets variables $colno and $tabname from another script and these are correctly passed. Now I'm trying to gather strings into an array and pass this array onto conf_col_names.php, but there I get an undefined variable error if I refer to the array $columns. Any ideas why??? Please!

<HTML>
<HEAD>
<TITLE>Get column names</TITLE>
</HEAD>
<BODY>
<?
$columns[0]=$colno;
$columns[$colno+1]=$tabname;
echo"<font face=\"arial\" size=\"2\" color=\"#1c651c\">Table name : " . $columns[$colno+1] . "</font>" ;
echo "<BR><BR>";
echo"<font face=\"arial\" size=\"2\" color=\"#1c651c\">Column number : " . $columns[0] . "</font>" ;
$counter=1;
echo"<form action=\"conf_col_names.php\" method=\"post\">";
while ($counter < $colno+1)
{
echo "<BR>";
echo "<font face=\"arial\" size=\"2\" color=\"#1c651c\">Enter name of column " . $counter . " : </font>";
echo "<input type=\"text\" name=\"columns[$counter]\" size=\"15\" >";
$counter++;
}
echo"<BR>";
echo "<BR><input type=\"submit\" value=\"Enter\">";
echo "</form>";
?>
</BODY>
</HTML>
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

it looks like the 'counter' variable isn't being passed...

why don't you try:

Code: Select all

echo "<input type="text" name="columns&#1111;]" size="15" >";
it will just add on to the array
Fari
Forum Commoner
Posts: 42
Joined: Thu Sep 19, 2002 8:41 pm
Location: Timmins - Ontario

Post by Fari »

Hi!

I tried

Code: Select all

echo "<input type="text" name="columns&#1111;]" size="15" >";
with no success! Any other ideas??? :(
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

&lt;?php
&lt;HTML&gt; 
&lt;HEAD&gt; 
&lt;TITLE&gt;Get column names&lt;/TITLE&gt; 
&lt;/HEAD&gt; 
&lt;BODY&gt; 
&lt;?
var $columns;
$columns&#1111;0]=$colno; 
$columns&#1111;$colno+1]=$tabname; 
echo"&lt;font face="arial" size="2" color="#1c651c"&gt;Table name : " . $columns&#1111;$colno+1] . "&lt;/font&gt;" ; 
echo "&lt;BR&gt;&lt;BR&gt;"; 
echo"&lt;font face="arial" size="2" color="#1c651c"&gt;Column number : " . $columns&#1111;0] . "&lt;/font&gt;" ; 
$counter=1; 
echo"&lt;form action="conf_col_names.php" method="post"&gt;"; 
while ($counter &lt; $colno+1) 
{ 
echo "&lt;BR&gt;"; 
echo "&lt;font face="arial" size="2" color="#1c651c"&gt;Enter name of column " . $counter . " : &lt;/font&gt;"; 
echo "&lt;input type="text" name="columns&#1111;$counter]" size="15" &gt;"; 
$counter++; 
} 
echo"&lt;BR&gt;"; 
echo "&lt;BR&gt;&lt;input type="submit" value="Enter"&gt;"; 
echo "&lt;/form&gt;"; 
?&gt; 
&lt;/BODY&gt; 
&lt;/HTML&gt;
?&gt;
Does this work?
Fari
Forum Commoner
Posts: 42
Joined: Thu Sep 19, 2002 8:41 pm
Location: Timmins - Ontario

Post by Fari »

Hi!

Inclusion of

Code: Select all

var $columns;
generates a parse error

Parse error: parse error, unexpected T_VAR in c:\program files\apache group\apache\htdocs\test\get_col_names.php on line 7 ... so it doesn't seem to be working... but thanks anyway!
Fari
Forum Commoner
Posts: 42
Joined: Thu Sep 19, 2002 8:41 pm
Location: Timmins - Ontario

sorry guys {...sitting here petty sh@tfaced..}

Post by Fari »

mistyped the array name in the script the array is referred to! it's working now!!

Thanks - again and soorry for the time wasted!

Fari
Post Reply