473,395 Members | 1,978 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.

Problems with error checking / control of POST variables

I have a small form that on button press submits to a PHP file for further
processing into a database. I have to change the script as it allows
blank / nothing to be submitted to the database. The intention is that if
any of the two form fields are blank (empty) then the page is resent
stating that they have to fill in all the fields to post (to a database).

If I deliberately leave the fields blank and submit the form, querying the
database shows that both fields are zero / null - so nothing was entered in
to the database.

However, if I use an echo command to see what is going on (before the data
is entered into a database) I get the $TheName field with a "1" and the
$TheComment field with an unknown entry (it doesn't echo anything to the
screen - but it's not empty).

The code I've used to test this is:

$TheName = $_POST[gbName];
$TheComment = $_POST[gbComment];

if (($TheName = NULL) or ($TheComment = NULL))
{
echo 'Quick error check running:<BR>';
echo "Name: $TheName<BR>";
echo "Comment: $TheComment";
exit;
}

This does NOT execute as these fields are not empty. It only runs if I
change to:

if (($TheName = !NULL) or ($TheComment = !NULL))

Which is pointless as it will always execute with genuine entries.

Using the amended code below:

if (($TheName = !NULL) or ($TheComment = !NULL))
{
echo 'Quick error check running:<BR>';
}

echo "Name: $TheName<BR>";
echo "Comment: $TheComment";
I get the result that both the echoed lines are displayed as blank (no
"1").

Anyone know what's going on?

Dariusz
Jul 17 '05 #1
2 1945
Dariusz wrote:
(snip)
Anyone know what's going on?


The comparison operator is not "=" !!

When you do
if ($a = 7) something();
you're *not* comparing $a to 7 and executing something() if they're equal;

you are assigning 7 to $a, comparing the result of the assignment (which
is 7) to true (which is true) and executing something().
Probably you want to use "==":
if ($a == 7) something();

HTH
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
In article <2h************@uni-berlin.de>, Pedro Graca <he****@hotpop.com> wrote:
Dariusz wrote:
(snip)
Anyone know what's going on?


The comparison operator is not "=" !!


The word "Doh !" springs to mind. How I missed that one. Thanks for that.

Dariusz
Jul 17 '05 #3

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

Similar topics

3
by: | last post by:
Hello, Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But...
55
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems...
2
by: mb12036 | last post by:
All- Having a problem installing a DB2 client on a machine running AIX version 5.0. Client appeared to install one time succesfully, then was uninstalled and a reinstall was attempted. For...
0
by: Henry Reardon | last post by:
I need some help with migration. As I mentioned in my previous post, I am having migration problems after updating DB2 7.2 to DB2 8.2 and then applying FP8. I am running on Windows XP. None...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
2
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.