On Sat, 2002-08-03 at 06:05, Rich Hutchins wrote:
> Try referencing the $listbox variable in you SQL statement like this:
> 
> $sql = "insert into ".$listbox."
> values(NULL,'$date','$exercise','$reps','$comments')";
> 
> I'm guessing that it might also work like this:
> 
> $sql = "insert into '$listbox'
> values(NULL,'$date','$exercise','$reps','$comments')";
> 
> I think your core problem is that the $listbox variable is not being
> evaluated properly in the SQL statement. Once you solve that, you're good to
> go.
> 
> Hope this helps.
> 
> Rich

I tried both suggestions and neither are working. I am using the get
format for the form so I can see what is being sent, and I am getting
this:
http://192.168.1.53/workout-absflexor.php?exerciselist=%24listbox&exercise=80
&reps=12&comments=&submit=Send+Data

Notice that the $listbox variable is still not being sent. Just above
this is an echo statement which shows what's in that variable, and it
displays the expected result (see code below). I am at a loss as to why
this is not working.

If I replace the $listbox variable with the table name shown in the echo
statement, a connection is made and the query is completed.

--
Chip W
www.wiegand.org
[EMAIL PROTECTED]


> -----Original Message-----
> From: Chip Wiegand [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 03, 2002 12:51 AM
> To: phpdb
> Subject: [PHP-DB] problem getting form input field to become part of
> query statement
> 
> 
> I have a form with a select list and a hidden field to save the selected
> item. On submit another page is loaded with a few fields to be filled in
> and submitted to a table. Using get I see the data is being passed from
> the first page to the second properly, and the second page sends its
> data properly. The hidden field from the first page is to be used by the
> second page as the name of the table in the query. I have a place where
> I echo the contents of the hidden field just to be sure it is correct,
> and that does indeed show what I expect. I then make the query statement
> point to the variable but it always responds that it cannot find the
> table. The table does exist, the variable does contain the appropriate
> table name, but is not being replaced by the name. What am I doing
> wrong?
> 
> --
> Chip W
> www.wiegand.org
> [EMAIL PROTECTED]
> 
> Below is the code for the first page --
> 
> <html>
> <head>
> <title></title>
> </head>
> <body>
> <div align="center">
> <?
> $exercises=array("absflexor","absmachine","leglifts");
> 
> echo "<form action='workout-absflexor.php' method='get'>";
> echo "<table width='70%' border='0' align='center'>";
> echo "<tr><th align='center'><h2>Exercise Data Input</h2></th></tr>";
> echo "<tr><th align='center'><select name='listbox'>";
> echo "<option>$exercises[0]</option>";
> echo "<option>$exercises[1]</option>";
> echo "<option>$exercises[2]</option>";
> echo "</select><br><br>";
> echo "</th></tr></table>";
> echo "<input type='hidden' name='exerciselist' value='$listbox'>";
> echo "<input type='submit'>";
> echo "</form>";
> ?>
> </div>
> </body>
> </html>
> 
> And below is the code for the second page --
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
>   <head>
>     <title>Workout Data Entry Form</title>
> <style type="text/css">
>  body { background-color: aqua; }
>  div.c1 {text-align: center}
> </style>
>   </head>
>   <body>
>     <div class="c1">
>       <h2>Work-Out Data Entry Screen</h2>
>       <form action="<? PHP_SELF ?>" method="get">
>         <table summary="" width="60%" border="1" align="center"
> bgcolor="green">
>           <tr>
>             <th>Weight</th>
>             <td align="left"><input type="text" name="exercise"
> maxlength="4"></td>
>           </tr>
>           <tr>
>             <th>Reps</th>
>             <td align="left"><input type="text" name="reps"
> maxlength="4"></td>
>           </tr>
>           <tr>
>             <th>Comments</th>
>             <td colspan="2"><textarea cols="50" rows="3"
> name="comments">
>             </textarea></td>
>           </tr>
>         <tr><td><? echo $listbox; ?></td></tr>
>         </table>
>         <br />
>         <input type="submit" name="submit" value="Send Data" /> <input
> type="reset" />
>       </form>
>     </div>
>   <?
>   if(isset($submit)):
>   $db = mysql_connect("localhost","root","carvin");
>   if(!$db) error_message(sql_error());
>   mysql_select_db("workout",$db) or die ("Ack! Where's the database?");
>   $date = date("m-d");
>   $sql = "insert into $listbox
> values(NULL,'$date','$exercise','$reps','$comments')";
>   mysql_query($sql) or die ("Ack! No response when I queried the
> server!");
>   endif;
>   ?>
>   </body>
> </html>
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to