Thanks everyone.

> If there is no purpose, I would make the values of the inputs the values you
> want to store in your database.
> Muuch easier..
>

So I am trying to keep this simple and just assign the value with the
radio button and then insert it into mysql database, but with the
following code I am getting the mysql error: Unknown column '250kbps'
in 'field list' when I choose the first radio button.

I think it has to do with the value being a string, but I haven't been
able to figure out the fix.

Thanks everyone for your help in accomplishing one thing with many
differnt techniques. It is greatly appreciated.

Chris

#### Form ####

                                echo '<form method="post" action="">
                                        Store name: <input type="text" 
name="store_subject" /><br /><br />
                                        Market:';
                                
                                echo '<select name="store_mar">';
                                        while($row = mysql_fetch_assoc($result))
                                        {
                                                echo '<option value="' . 
$row['mar_id'] . '">' .
$row['mar_name'] . '</option>';
                                        }
                                echo '</select><br /><br />';   
                                        
                                echo 'Broadband speed test results: <br /><br />
                                        0-250kbps<input type="radio" 
name="post_tptest" value="0-250kbps" />|
                                        250-300kbps<input type="radio" 
name="post_tptest" value="250-300kbps" />|
                                        300-400kbps<input type="radio" 
name="post_tptest" value="300-400kbps" />|
                                        400-600kbps<input type="radio" 
name="post_tptest" value="400-600kbps" />|
                                        600kbps-3.8mbps<input type="radio" 
name="post_tptest"
value="600kbps-3.8mbps" /><br /><br />
                                        Store visit details: <br /><br />
                                        <textarea name="post_content" 
/></textarea><br /><br />
                                        <input type="submit" value="Add a store 
visit" />
                                 </form>';
                        }
                }
        }


#### Insert Code ####

                                $sql = "INSERT INTO
                                                        posts(post_content,     
                                                        
                                                                  post_date,
                                                                  post_tptest,
                                                                  post_store,
                                                                  post_by)
                                                VALUES
                                                        ('" . 
mysql_real_escape_string($_POST['post_content']) . "',
                                                                  NOW(),
                                                                  " . 
$_POST['post_tptest'] . ",
                                                                  " . $storeid 
. ",
                                                                  " . 
$_SESSION['user_id'] . "
                                                        )";
                                $result = mysql_query($sql);
                                
                                if(!$result)
                                {
                                        //something went wrong, display the 
error
                                        echo 'An error occured while inserting 
your post. Please try
again later.<br /><br />' . mysql_error();
                                        $sql = "ROLLBACK;";
                                        $result = mysql_query($sql);
                                }
                                else
                                {
                                        $sql = "COMMIT;";
                                        $result = mysql_query($sql);
                                        
                                        //after a lot of work, the query 
succeeded!
                                        echo 'You have succesfully created <a 
href="store.php?id='.
$storeid . '">your new store visit</a>.';
                                }
                        }
                }
        }
}

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

Reply via email to