change print("<OPTION VALUE=$var>$var</OPTION>");
to     print qq(<OPTION VALUE="$var">$var</option>);
 
Your quotes are messing you up, in order to pass a value with a space, it must be quoted in the HTML.
-----Original Message-----
From: Margaret Quinn [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 9:22 AM
To: [EMAIL PROTECTED]
Subject: Delimiting at spaces causes query problem


 
The code below pulls out a list of fields from a database and populates a list box with them.
 
print qq!<form method="POST" action="whatever.cgi">!;
$SQL = "SELECT DISTINCT MachineNames.MachineName FROM MachineNames WHERE NOT(((MachineNames.MachineName)=''))ORDER BY MachineName ASC ";
&SQL; #runs the sql command
 print qq!<font size="3"><b>Recorder</b></font>\n!;
 print qq!<select name="rec">!;
 
 while ($db->FetchRow())
 {
  @values = $db->Data();
  foreach $var (@values)
  {  
   print("<OPTION VALUE=$var>$var</OPTION>");
  }
 } 
 print ("</select>");
&CLOSEDB;
print("</form>"); 
According to what item the user picks i want to pass it onto another query - but it doesn't seem to allow me to pass in a field with spaces?? anyone know why 
 
I read the value selected in :
my $rec = param("rec");
then pass it to another sql statement :
 $sql = qq!SELECT TransientsList.Location, TransientsList.MachineName, TransientsList.TriggerTime,   TransientsList.Duration, TransientsList.Description, TransientsList.CauseOfTrigger,   TransientsList.Classified, TransientsList.RecNum
  FROM TransientsList where ((TransientsList.MachineName)='$rec') ORDER BY TransientsList.MachineName!;
 
If $rec "Hello" this query will work.
However,  "Hello 1" won't anybody know how i get around this ? 

Reply via email to