my code erronousely changes the variable

This is a discussion on my code erronousely changes the variable within the PHP Language forums, part of the PHP Programming Forums category; I don't get it. can anyone help me with this ? It's a simple preceding checkbox, either yes or ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-09-2003
george
 
Posts: n/a
Default my code erronousely changes the variable

I don't get it. can anyone help me with this ? It's a simple preceding
checkbox, either yes or no - if yes, add the details to a $db and if
no, then don't. But I get the original variable being switched from
yes to no, or from no to yes, and either way, the database gets
accessed.

(code page1)
(snip)
<SELECT NAME="radiobutton" SIZE="1"><OPTION VALUE="yes" selected>yes
please</OPTION><OPTION VALUE="no">no thanks</OPTION></SELECT>
(/snip)(code)


(code page2)
-----------
$cname = $_POST['cname'];
$sname = $_POST['sname'];
$radio = $_POST['radiobutton'];
//collect the radio value
$mail = "";
$mail=$radio;
// see what I've got
echo $mail;
//then it is supposed to be yes or no and act accordingly
if ($mail = "yes") {
// stick into database
$host = "(host)";
$login_name = "(name)";
$password = "(password)";
MySQL_connect("$host","$login_name","$password");
MySQL_select_db("(database") or die("Could not select database");
$sql = "INSERT INTO (table) ( cname, sname) VALUES
('$cname','$sname')";
// save the result for later on
$result = mysql_query($sql);
if ($result) {
$post = "Yes, thanks";
} else {
$post = "No";
}
}
// checking what I've got
echo $mail;

(/code)
Reply With Quote
  #2 (permalink)  
Old 09-09-2003
Jon Kraft
 
Posts: n/a
Default Re: my code erronousely changes the variable

george <russell@waiheke.co.nz> wrote:

> I don't get it. can anyone help me with this ? It's a simple preceding
> checkbox, either yes or no - if yes, add the details to a $db and if
> no, then don't. But I get the original variable being switched from
> yes to no, or from no to yes, and either way, the database gets
> accessed.


> //then it is supposed to be yes or no and act accordingly
> if ($mail = "yes") {


if ($mail == "yes") {

JOn
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0