473,625 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

operand a database value?

5 New Member
I'm new to PHP so bear with me.
This is part of some php that checks if an entered "code" is valid, then it sends additional info to a sql database.


I want to check field2 and if the value is "valueB" then goto a different web page. Here's the section of PHP with that "if" statement(line 28). it's not working for me

---------------------------------------------------------------


[PHP]global $ValidateMessag e;

$code = $_REQUEST['code'];

if (strlen($code) == 0)
{
$ValidateMessag e="";
}
else if (Code_DecodeCod e($code) === TRUE)
{
global $gCms;

$db =& $gCms->GetDb();

$code = $db->qstr($_REQUE ST['code']);
$field1 = $db->qstr($_REQUE ST['field1']);
$field2 = $db->qstr($_REQUE ST['field2']);
$field3 = $db->qstr($_REQUE ST['field3']);


$sql = "INSERT INTO table SET code=$code, field1=$field1, field2=$field2, field3=$field3;
$db->query($sql);


if (@mysql_affecte d_rows() == 1)
{

if($field2 == "valueB") {
header("Locatio n: http://www.******");
exit;

} else {

header("Locatio n: http://www.******");
exit;
$ValidateMessag e = "Code accepted.";
}

}
else
$ValidateMessag e = "$code has already been submitted";
}
else
{
$ValidateMessag e = "$code is not valid";
}

echo "$ValidateMessa ge";[/PHP]
Sep 19 '07 #1
5 1614
pbmods
5,821 Recognized Expert Expert
Heya, RendFox. Welcome to TSDN!

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Sep 19 '07 #2
kovik
1,044 Recognized Expert Top Contributor
This is the actual code? Including the parse error...?
Sep 19 '07 #3
rendfox
5 New Member
Hi, thanks guys.

So all the data is being entered into the db fine.
now, if field2 is a radio button and the value is stored as "on", I want to forward the user to a different url.

I thought this line would do it:
Expand|Select|Wrap|Line Numbers
  1. if($field2 == "on") {
  2.      header("Location: http://www.******");
  3.     exit;
  4.  
But it's not working for me. The user gets sent to the second url, no matter what the value of field2 is.

I left out the function Code_DecodeCode ; don't want to post that. Assume that value === TRUE.

as far as I know, I'm not getting a parse error.
Sep 19 '07 #4
rendfox
5 New Member
OK, I threw a
Expand|Select|Wrap|Line Numbers
  1. $field2 = $_GET['field2'];
  2.  
in there and it works now.

I guess
Expand|Select|Wrap|Line Numbers
  1. $field2 = $db->qstr($_REQUEST['field2']);
  2.  
doesn't hold the variable value in $field2.
Sep 19 '07 #5
pbmods
5,821 Recognized Expert Expert
Heya, Rendfox.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
8115
by: erkki | last post by:
Hi, is there some DB parameter or JDBC driver property that says 'LIKE' search should not be case sensitive? I use DB2 Express 8.1.5 and Websphere 5.0.2. I don't use WAS Connectionpool in this case. UCASE(fieldname) is not an option.
6
13564
by: BlueTrin | last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a virtual class. However I am stuck with the overriding of evaluation and gradiant functions. cStepCurveEvaluator.cpp cStepCurveEvaluator.cpp(14) : error C2296: '.*' : illegal, left operand
2
4053
by: Dylan Parry | last post by:
Hi folks, I've been getting the following warning when compiling my code, "Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first", and although it doesn't have any detrimental effect, I would love to be able to get rid of it. The code that it refers to is: public static int RGB(byte r, byte g, byte b) {
10
2333
by: Agnes | last post by:
Dim authCommand As String = "select count(*) as iRowCount from coinfo where loginid = @cocode and ((curr_pwd = @pwd and effdate > getdate()) or (eff_pwd = @pwd and effdate <= getdate()))" Dim oleCommand As New OleDbCommand(authCommand, authConnection) oleCommand.Parameters.Add(New OleDbParameter("@cocode", OleDbType.VarChar, 10)) oleCommand.Parameters("@cocode").Value = UserName oleCommand.Parameters.Add(New OleDbParameter("@pwd",
1
1584
by: programmingChick | last post by:
I have a program where I want to accept an operand (from a file) and apply that operand to some integers. How should I do that? Is the best way to convert it to its ascii character then figure out which operand it is from there?
19
2493
by: Rajesh S R | last post by:
Consider the following code: int main() { struct name { long a; int b; long c; }s={3,4,5},*p; p=&s;
34
2119
by: linq936 | last post by:
Hi, I just did the following test: 1:void main(void){ 2: int p = 1; 3: int* pp = &p; 4: int c = p * pp; 5: int d = p + pp; 6:}
4
24562
by: =?Utf-8?B?TGVvIExleXM=?= | last post by:
Hi, The code below generates a compile error on line 3 (dim d...) Dim o As Object = "1900-01-01" Dim s As String = TryCast(o, String) Dim d As DateTime = TryCast(o, DateTime) The error is : TryCast operand must be reference type, but 'Date' is a value type.
7
5039
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are involved. The problem is that comparisons between signed and unsigned values are machine- dependent, because they depend on the sizes of the various integer types. For example, suppose that int is 16 bits
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6118
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.