...

View Full Version : Couple problems..



cyphix
05-14-2004, 06:25 PM
Having problems with this if statement..

I'm checking 2 form fields & their default value is "0" & I only want people to change them if they want to input another number... I don't want them taking away the "0" & leaving it blank.

Thing is... this works if one is blank, but if I leave both blank I don't get any errors.



if ($fmtext or $fmcheckbox == '') {

echo "Please leave all options you don't need set to zero & do not modify them.";

exit();

}


Also, how can you insert the value of a variable into a bunch of text without spaces in the text?

Like this...

$sn = 23;



echo "iam$sntoday"; // Doesn't work
echo "iam"$sn"today"; // Doesn't work
echo "iam($sn)today"; // Returns the brackets also but gets the value correct


Any tips?

Thanks!

Serex
05-14-2004, 06:36 PM
hey...

1.


if ($fmtext == "" || $fmcheckbox == "")
{
echo "Please leave all options you don't need set to zero & do not modify them.";
}

// or if you really need to, you could use a set of elseifs

if ($fmtext == "")
{
echo "Please leave all options you don't need set to zero & do not modify them.";
}
elseif ($fmcheckbox == "")
{
echo "Please leave all options you don't need set to zero & do not modify them.";
}

|| is used as OR and u need to check both cases

2.


$sn = 23;
echo "I am " . $sn . " Today";

You can use the fullstop (.) to join/glue strings and variables together

:thumbsup:

cyphix
05-14-2004, 07:57 PM
Thanks! Got the first working but not the second. :(



echo "<input type=\"text\" name=\"'fmtextquestion' . $sn . '-$textnum2'\" size=\"4\">\n";

Outputs..



<input type="text" name="'fmtextquestion' . 105 . '-1'" size="4">

Spookster
05-14-2004, 08:10 PM
Before you post, read our: Rules & Posting Guidelines

Specifically section 2 of the posting guidelines. Your subject line is not acceptable.

cyphix
05-14-2004, 08:28 PM
Sorry, I thought of that but it was kinda hard to explain them both in the title.

Spookster
05-14-2004, 10:15 PM
Sorry, I thought of that but it was kinda hard to explain them both in the title.

If it is not possible to be specific then a general subject is better like PHP and Form Fields or Problems with an "if" statement.

Also if the two questions are unrelated then they should be put in two seperate topics.

We do this to make it easier for others to find answers to their questions when they use the search feature and not have to weed through a lot of titles that are not obvious or have the discussion buried inside of a thread.

cyphix
05-14-2004, 11:04 PM
Yes... thats's cool.

If I have a few things to cover I thought it was usually best to keep them in one thread as most other forums frown upon creating multiple threads when you could have put it all in one.

Btw, I solved my problem..



$texthm = "fmtexthm" . $sn . "-$textnum2";

echo "<input type=\"text\" name=\"$texthm\" size=\"4\">\n";


:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum