473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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)
Jul 16 '05 #1
1 1562
george <ru*****@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
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Delta | last post by:
Drop Down Menu Mozilla : work well widowed elements such as drop downs, except for flash movies IE : work well so far http://pwp.netcabo.pt/falmartins/index.htm
1
by: LenS | last post by:
If this is the wrong place to post this, please advise better place. Otherwise, I have created the following python program and it works. Running on XP. I think I am now at that stage of learning...
4
by: Bobbak | last post by:
Hello All, I was wondering if it is possible to do this; I have a form that has number of text boxes that when a button is clicked it turns into combo boxes, simply by toggling the visibility to...
6
by: John | last post by:
Hi I have a front-end/back-end access app. I have created a replication set between the backend on a server an the backend on a laptop. My question is; How can I cause the synchronisation to...
16
by: Richard | last post by:
Hi, I am passing a structure to a subroutine where the passed parameter has been declared as ByVal. However, changes made to the passed variable inside the subroutine flow through to the...
10
by: dbuchanan | last post by:
Hello, >From time to time my vb2005 form disappears and is replaced by the following errors. Rebuilding the application never helps. However the errors never affects the operation of my...
24
by: Gaijinco | last post by:
I found one of that problems all of us have solve when they begin programming: given 3 numbers print the greater and the lesser one of the set. I was trying to remember the if-then-else...
5
by: AMP | last post by:
Hello, I have a Form level variable: public partial class Form1 : Form { byte rxHeader = 0;.............................. That gets passed from one function to another: if...
2
by: Paul Ritchie | last post by:
A few years ago I used a Profiler (I forget the name) on my Delphi code at the time and got fantastic results showing both: a) lines of code that took the longest to execute and b) lines of code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.