473,395 Members | 1,652 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,395 software developers and data experts.

operand a database value?

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 $ValidateMessage;

$code = $_REQUEST['code'];

if (strlen($code) == 0)
{
$ValidateMessage="";
}
else if (Code_DecodeCode($code) === TRUE)
{
global $gCms;

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

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


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


if (@mysql_affected_rows() == 1)
{

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

} else {

header("Location: http://www.******");
exit;
$ValidateMessage = "Code accepted.";
}

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

echo "$ValidateMessage";[/PHP]
Sep 19 '07 #1
5 1601
pbmods
5,821 Expert 4TB
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 Expert 1GB
This is the actual code? Including the parse error...?
Sep 19 '07 #3
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
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 Expert 4TB
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
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...
6
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...
2
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...
10
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...
1
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...
19
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
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
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...
7
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.