If you just need to put it in the database, you dont need a form to do that.. just open a connection to your db, and query it in.
read about mysql functions in the php manual.. specifically mysql_connect, mysql_select_db and mysql_query , i beleive there is a functional example of all you need on the introduction page for the mysql functions in the manual. Jason "M. Sokolewicz" <[EMAIL PROTECTED]> wrote: > > Aidan wrote: > > Please help, I'm tearing what remains of my hair out here. > > I've got a MySQL database where I've defined one of the table fields as an > > integer. > > Using PSP I've passed a session variable and can echo it to the screen using > > <?php echo intval($clin_id) ?>. So the session variable exists and can be > > echoed > > I now want to pass this session variable to the database into the field I've > > defined as an integer > > > > I've set up a form to submit other variables to the backend database and > > they all work apart from this field. > > > > I'm using a hidden field to pass the variable and I am using > > > > <input name="p_clin_id" type="hidden" id="p_clin_id" > > value="intval('$clin_id')"> > that line doesn't make any sense to me... what are you doing there? > you're freely mixing PHP and HTML without denoting what is what. > an example that WOULD work would be: > echo '<input name="p_clin_id" type="hidden" id="p_clin_id" > value="'.intval($clin_id).'">'; > > or maybe > ?> > <input name="p_clin_id" type="hidden" id="p_clin_id" > value="<?php echo intval($clin_id);?>"> > <?php > > So, mixing HTML and PHP without denoting what is what is the first > mistake. The second one is the actual function call: > intval('$clin_id'); > > Now, when you put something between SINGLE quotes, it is read LITERALLY, > meaning it *will not* substitute variables for their value. eg: > echo '$clin_id'; > > will output: > $clin_id > > However, > echo "$clin_id"; > will output the VALUE of $clin_id (eg. 12) > > So, I think that instead of > intval('$clin_id') you actually meant intval("$clin_id"), or, cleaner, > intval($clin_id) (since intval isn't expecting a string anyway, and even > if it were, it would change it to one itself. No need to do extra work > for nothing.) > > The 3rd point about this all... if you get the value from the database, > and it's an integer there, then why are you converting it to an integer > AGAIN?? :| just using $clin_id instead of intval($clin_id) is surely > faster (seen as no extra functions need to be called). > > > > > What I don't understand is that if I can echo the variable what am I missing > > in formatting a sessio variable to make it passable to the database. It mus > > be something basic and I've looked through several books (from where I got > > the intval function) but obviously in the wrong place. > > > > I would be grateful for any advice. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php