[PHP-DB] Inserting checkbox data

2002-10-25 Thread Graeme McLaren
Hi all, I'm having a problem inserting a value from a checkbox into a MySQL DB.  I can 
print out what the variable holds, the problem is it just won't go into the DB.  Weird 
thing is when I login to SSH there isn't a NULL value for it instead that field is 
just blank.

Anyone got any ideas what the problem is?


The HTML that is used for the checkbox is:  

Gift Wrapping: input type=checkbox Name=GiftWrapping[] Value=\Y\


So it should theoretically insert Y into the DB

Here is the code that appears to be causing the problem:

$number=count($GiftWrapping); 
 for($a=0;$a=$number;$a++)
 { 
 echo $GiftWrapping[$a];
 $GW = $GiftWrapping[$a]; 
 echo $GW;
 } 

if ($Submit == Submit) {
  $sql = INSERT INTO SiteMember SET
FirstName = '$FirstName',
LastName = '$LastName'
Username = '$Username',
Password = '$Password',
GiftWrapping = '$GW';
 }


Thank you in advance for any help.

Graeme :)


Public Sub House()

On Error Resume drink

 If Pint.empty = True Then
 Pint.refill
   Else
 Pint.drink
 End if

stomach.add Pint

MsgBox  I've had    stomach.count   Pints
MsgBox VERY DRUNK

End Sub




Re: [PHP-DB] Inserting checkbox data

2002-10-25 Thread Mihail Bota
Graeme,

first, extend the for loop over the if and the query for insertion of
data. As you have it now, it just inserts the last element of the array.
second, I think that the for loop should be $a$number. if you put =,
then the loop is processing the array with the last value not assigned by
you (an extra element in the array).
Hope it helps.

Mihai

On Fri, 25 Oct 2002, Graeme McLaren wrote:

 Hi all, I'm having a problem inserting a value from a checkbox into a MySQL DB.  I 
can print out what the variable holds, the problem is it just won't go into the DB.  
Weird thing is when I login to SSH there isn't a NULL value for it instead that field 
is just blank.

 Anyone got any ideas what the problem is?


 The HTML that is used for the checkbox is:

 Gift Wrapping: input type=checkbox Name=GiftWrapping[] Value=\Y\


 So it should theoretically insert Y into the DB

 Here is the code that appears to be causing the problem:

 $number=count($GiftWrapping);
  for($a=0;$a=$number;$a++)
  {
  echo $GiftWrapping[$a];
  $GW = $GiftWrapping[$a];
  echo $GW;
  }

 if ($Submit == Submit) {
   $sql = INSERT INTO SiteMember SET
 FirstName = '$FirstName',
 LastName = '$LastName'
 Username = '$Username',
 Password = '$Password',
 GiftWrapping = '$GW';
  }


 Thank you in advance for any help.

 Graeme :)


 Public Sub House()

 On Error Resume drink

  If Pint.empty = True Then
  Pint.refill
Else
  Pint.drink
  End if

 stomach.add Pint

 MsgBox  I've had    stomach.count   Pints
 MsgBox VERY DRUNK

 End Sub




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




RE: [PHP-DB] Inserting checkbox data

2002-10-25 Thread Hutchins, Richard
In addition to what Mihail had to say, I saw a couple of minor things as
well. I'm not sure if they're the cause of or solution to the problem you're
experiencing.

First, I'm pretty sure that a value of value=\Y\ is not valid HTML. I
don't know what it does to your name/value pair when you POST the data from
the page, but I'm pretty sure it's invalid HTML. HTML wants value=Y; it
doesn't like the slashes.

Second, I noticed you're missing a comma in your SQL statement between
$LastName and $Username. That would probably cause your SQL statement to
error out.

Just my two cents.

 -Original Message-
 From: Graeme McLaren [mailto:mickel;ntlworld.com]
 Sent: Friday, October 25, 2002 2:40 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Inserting checkbox data
 
 
 Hi all, I'm having a problem inserting a value from a 
 checkbox into a MySQL DB.  I can print out what the variable 
 holds, the problem is it just won't go into the DB.  Weird 
 thing is when I login to SSH there isn't a NULL value for it 
 instead that field is just blank.
 
 Anyone got any ideas what the problem is?
 
 
 The HTML that is used for the checkbox is:  
 
 Gift Wrapping: input type=checkbox Name=GiftWrapping[] Value=\Y\
 
 
 So it should theoretically insert Y into the DB
 
 Here is the code that appears to be causing the problem:
 
 $number=count($GiftWrapping); 
  for($a=0;$a=$number;$a++)
  { 
  echo $GiftWrapping[$a];
  $GW = $GiftWrapping[$a]; 
  echo $GW;
  } 
 
 if ($Submit == Submit) {
   $sql = INSERT INTO SiteMember SET
 FirstName = '$FirstName',
 LastName = '$LastName'
 Username = '$Username',
 Password = '$Password',
 GiftWrapping = '$GW';
  }
 
 
 Thank you in advance for any help.
 
 Graeme :)
 
 
 Public Sub House()
 
 On Error Resume drink
 
  If Pint.empty = True Then
  Pint.refill
Else
  Pint.drink
  End if
 
 stomach.add Pint
 
 MsgBox  I've had    stomach.count   Pints
 MsgBox VERY DRUNK
 
 End Sub
 
 

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




Re: [PHP-DB] Inserting checkbox data

2002-10-25 Thread Graeme McLaren
Mihail, thanx for your advice, I've got it going now ! :)  Thank you !

Richard, your points were valid, the HTML code with the slashes was just a
copy n' paste from a PHP script and the comma I think I deleted by accident
so its all sorted now.


Thank you again!

Graeme :)
- Original Message -
From: Mihail Bota [EMAIL PROTECTED]
To: Graeme McLaren [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, October 25, 2002 7:47 PM
Subject: Re: [PHP-DB] Inserting checkbox data


 Graeme,

 first, extend the for loop over the if and the query for insertion of
 data. As you have it now, it just inserts the last element of the array.
 second, I think that the for loop should be $a$number. if you put =,
 then the loop is processing the array with the last value not assigned by
 you (an extra element in the array).
 Hope it helps.

 Mihai

 On Fri, 25 Oct 2002, Graeme McLaren wrote:

  Hi all, I'm having a problem inserting a value from a checkbox into a
MySQL DB.  I can print out what the variable holds, the problem is it just
won't go into the DB.  Weird thing is when I login to SSH there isn't a NULL
value for it instead that field is just blank.
 
  Anyone got any ideas what the problem is?
 
 
  The HTML that is used for the checkbox is:
 
  Gift Wrapping: input type=checkbox Name=GiftWrapping[] Value=\Y\
 
 
  So it should theoretically insert Y into the DB
 
  Here is the code that appears to be causing the problem:
 
  $number=count($GiftWrapping);
   for($a=0;$a=$number;$a++)
   {
   echo $GiftWrapping[$a];
   $GW = $GiftWrapping[$a];
   echo $GW;
   }
 
  if ($Submit == Submit) {
$sql = INSERT INTO SiteMember SET
  FirstName = '$FirstName',
  LastName = '$LastName'
  Username = '$Username',
  Password = '$Password',
  GiftWrapping = '$GW';
   }
 
 
  Thank you in advance for any help.
 
  Graeme :)
 
 
  Public Sub House()
 
  On Error Resume drink
 
   If Pint.empty = True Then
   Pint.refill
 Else
   Pint.drink
   End if
 
  stomach.add Pint
 
  MsgBox  I've had    stomach.count   Pints
  MsgBox VERY DRUNK
 
  End Sub
 
 



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