I've been working on PHP for some time but today when I saw this it came as new to me:
if(preg_match('/foo.*bar/','foo is a bar')):
echo 'success ';
echo 'foo comes before bar';
endif;
To my surprise it also runs without error. Can anyone enlighten me?
Thanks to all :)
...
I have a textbox UserName and a Check Availability button next to it..... I have checked the availability by passing UserName textbox value..... But it doesn't seem to work....
Here is what i am doing?
echo $UserName = $_GET['CheckUsername'];
$_SESSION['state'] = $State;
$queryres = "SELECT dUser_name FROM tbl_login WHERE dUser_name='$...
I'm just getting into Python and I really like the terseness of the syntax. However; is there an easier way of writing an if-then statement so it fits on one line?
For example; say I have the simple test:
if count == N:
count = 0
else:
count = N + 1
is there a simpler way of writing this? I mean, in Objective-C I would write ...
Hello,
What do you think , does the Stored Procedure always return 1 ?
I am concerned about the if exists(..)
BEGIN
DECLARE @IsUserExisting bit
SET NOCOUNT ON
IF Exists
(
Select null FROM G_User WHERE
SamAccountName = @SamAccountName
AND NetBIOSDomainName = @NetBIOSDomainName
)
BEGIN
SET @IsUserExi...
Hi,
I need to determine what file type a file is and then perform a certain action for it. this seems to work fine for some types, however all media types such as videos and sound files get mixed up. I determine the file type by doing this:
BOOL matchedMP3 = ([[rowValue pathExtension] isEqualToString:@"mp3"]);
if (matchedMP3 == ...
Hi everyone,
Is there any good alternative for the plain if statements in PHP? I know about switch, but I'll guess that there's some more refined alternative out there that comes handy when working with really big if statements.
Thanks a lot,
...
If you go to a store and ask "Cash or Credit?" they might simply say "Yes." This doesn't tell you anything as you posed an OR statement. if(cash || credit)
With humans it's possible that they might respond "Both" to that question, or "Only {cash | credit}." Is there a way (or operator) to force the a statement to return the TRUE portio...
I've written the following if-statement in Java:
if(methodName.equals("set" + this.name) ||
isBoolean() ? methodName.equals("is" + this.name) :
methodName.equals("get" + this.name)) {
...
}
Is this a good practice to write such expressions in if, to separate state from condition? And can this expression be si...
I am trying to set up a MySQL trigger that does the following:
When someone inserts data into databaseA.bills, it verifies if databaseB.bills already has that row, if it doesn't, then it does an additional insert into databaseB.bills.
Here is what I have:
CREATE TRIGGER ins_bills AFTER INSERT ON databaseA.bills
FOR EACH ROW
BEGIN
...
I'm new to Python, so this is probably a simple scoping question. The following code in a Python file (module) is confusing me slightly:
if __name__ == '__main__':
x = 1
print x
In other languages I've worked in, this code would throw an exception, as the x variable is local to the if statement and should not exist outside of it....
I use this for checking an existing emailId in my table and inserting it...It works fine how to show message to user when he tries to register with an existing mailId....
if (!taxidb.Registrations.Where(u => u.EmailId == reg.EmailId).Any())
{
taxidb.Registrations.InsertOnSubmit(reg);
taxidb.SubmitChanges();
}
and my control...
Hi Everyone,
I use this pattern to test for undefined and null values in ActionScript/Flex :
if(obj) {
execute()
}
Unfortunately, a ReferenceError is always thrown when I use the pattern to test for child objects :
if(obj.child) {
execute()
}
ReferenceError: Error #1069: Property child not found on obj and there is no defau...
I am trying to echo the action for my form if a post equals 'paypal'
This is what I have:
<?php if $_POST['method'] == 'paypal' echo 'action="paypal/process.php"' else echo 'action="moneybookers/process.php" '?>
Do i need to print the variable before I do this? what am I doing wrong?
I get this error:
Parse error: syntax error, un...
Is there really any difference between using
If(this)
{
}
Else If(that)
{
}
Else
{
}
or using,
If(this)
{
}
If(that)
{
}
Else
{
}
?
Does one execute any faster? Does the compiler or architecture make any difference?
...
First if condition
if(Txt1.Text != "" && Txt2.Text != "")
Second if condition
if((Txt1.Text && Txt2.Text) != "")
Is there any diff between these two conditional statement?
...
I have this code:
<?php
if ( $amount < 5 ) {
echo 'Credit Balance low! You have';
echo $amount;
echo ' remaining credits.';
} else {
echo 'No recent alerts...';
}
?>
Where it says echo $amount; I want to echo $00.00 if the value of $amount == 0. How would I include this in my code?
...
How do I get this to not display when you first go to the page???
if ($error) {
echo "Error: $error<br/>";
}
if ($keycode) {
echo "Keycode: $keycode<br/>";
}
...
Hi all. I have a following source code php+js: http://pastebin.org/277948
I want to rewrite it using pure JS, but can’t imagine the way.
Any advices are appreciated.
...
Is there a better way to write the following conditional in javascript?
if ( value == 1 || value == 16 || value == -500 || value == 42.42 || value == 'something' ) {
// blah blah blah
}
I hate having all of those logical ORs strung together. I'm wondering if there is some kind of shorthand.
Thanks!
...
I tried the following && conditional for my if statement and I get a "bad range" error:
<% if (from_today(contact, call.days) == 0..7) && (show_status(contact, call) == 'no status') %>
Why and how can I fix it? The only other way I could do it was to have a second nested if statement and break it apart...not pretty :(
...