473,473 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to suppress a value with ( ) ? : ;

Claus Mygind
571 Contributor
I want to suppress the e: in the code below when the content of the email column is blank. I have tried several different methods and can not figure out why I always get the "e: "

the condition always returns false even when the the content of the email column is blank/empty or whatever you want to call it.

where is my coding error?

Expand|Select|Wrap|Line Numbers
  1. ... some more data added to $cVal
  2. $cVal .= ( (empty($c["EMAIL"]))?"": (" e: ".$c["EMAIL"]) );
  3.  
  4. echo $cVal;
  5.  
Feb 7 '11 #1
4 1717
dlite922
1,584 Recognized Expert Top Contributor
var_dump($c["EMAIL").

What do you get?

If there's a space in there, empty will return false and thus tack on "e:" to your space to get "e: " as the final value in $cVal.


Dan
Feb 7 '11 #2
Claus Mygind
571 Contributor
Ok most likely there is a blank space. in my dBase a blank " " is still considered empty.

How do I test for empty in php where there may or may not be a blank?
Feb 7 '11 #3
dlite922
1,584 Recognized Expert Top Contributor
Use Trim():

Expand|Select|Wrap|Line Numbers
  1. $cVal .= empty(trim($c["EMAIL"])) ? "" : " e: ${c["EMAIL"]}";
  2.  
Trim will remove any extra spaces in the front and back. If all you have is space, then of course it will return an empty string ("").

Cheers,


Dan
Feb 8 '11 #4
Claus Mygind
571 Contributor
Have not had the chance to test this out yet so cannot report on best answer just now.
Feb 17 '11 #5

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

Similar topics

6
by: Krishna Srinivasan | last post by:
I have a form with check boxes. When accessing a check box element that is not checked, I get a notice (Notice: Undefined variable..). Is there a way to hide these notices and warning in PHP code...
9
by: Doug Ly | last post by:
Hi, When I run this query using WinSQL to connect to a DB2 database, it gave me the warning: Error: SQLSTATE 01003: Null values were eliminated from the argument of a column function. ...
4
by: David Peach | last post by:
Hello, hope somebody here can help me... I have a query that lists defects recorded in a user defined date range. That query is then used as the source for a Cross Tab query that cross-tabs count...
6
by: Ron St-Pierre | last post by:
Is there a way 'within' psql to suppress output? One of our cron scripts calls a sql file which contains various database commands (ALTER TABLEs, UPDATEs, etc) and various user-defined functions....
2
by: dongdong | last post by:
for example: re.sub('<a( +)+\s?>*</a>','',' asd ga<a target="_blank" href="http://www.sine.com" class="wordstyle"> asdgasdghae rha</a>') I wish to get the return value "asd ga asdgasdghae...
5
by: Antonio | last post by:
Hello, everyone. Is there a way to not display a certain value in a datagrid cell? I have a datagrid for subscriptions and ebooks and if there isn't an e-book listed, the value from the...
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
1
by: rn5a | last post by:
A custom server control has a Button. Namespace Confirm Public Class ShowConfirm : Inherits Button Private strConfirmMsg As String Public Property ConfirmMessage() As String Get...
4
by: Steve | last post by:
Hi All, I've picked up the PyParsing module and am trying to figure out how to do a simple parsing of some HTML source code. My specific problem is dealing with an <TD></TDelement that is...
0
by: dragon52 | last post by:
Hi there, I have records in the form of scorecards. Each scorecard has fields "type" and "score". eg typeA 2.3 typeB 3.3 typeA 2.0 typeC 1.9 typeB 1.1
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
1
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...
0
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,...
1
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...
0
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...

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.