Page 1 of 1

Passing an array with URL

Posted: Fri Sep 20, 2002 7:54 pm
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>

Posted: Fri Sep 20, 2002 9:02 pm
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

Posted: Sat Sep 21, 2002 8:38 am
by Fari
Hi!

I tried

Code: Select all

echo "<input type="text" name="columns&#1111;]" size="15" >";
with no success! Any other ideas??? :(

Posted: Sat Sep 21, 2002 9:12 am
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?

Posted: Sat Sep 21, 2002 10:14 am
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!

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

Posted: Sat Sep 21, 2002 10:37 am
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