|
-
Jul 14th, 2005, 12:53 AM
#1
Thread Starter
Admodistrator
Parse errors?
PHP Code:
<html>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"
<input type="hidden" name="send" value="1">
<p>Name1<input type="text" name="Name1" /></p>
<p>Name2<input type="text" name="Name2" /></p>
<p>Name3<input type="text" name="Name3" /></p>
<p>Name4<input type="text" name="Name4" /></p>
<p>Name5<input type="text" name="Name5" /></p>
<p> <input type = "Submit" name = "Submit"/><p>
</form>
<?php
If($_POST[send] == "1"){
$Number = 1;
While($Number < 5){
If($_POST[$Number] <> ""){
echo($_POST['Name'[$Number]);
$Number++
}
}
</html>
right here is the error:
PHP Code:
If($_POST[$Number] <> ""){
echo($_POST['Name'[$Number]);
$Number++
anyone know?
-
Jul 14th, 2005, 01:06 AM
#2
Re: Parse errors?
u mistook the "["... make it "."
if you wanted to concatenate 'Name' with $ number... and get the result from post
-
Jul 14th, 2005, 01:07 AM
#3
Re: Parse errors?
also there is not closing ";" on $number++
-
Jul 14th, 2005, 01:08 AM
#4
Re: Parse errors?
also where is the closing for this if?
[phpcode]
If($_POST[send] == "1"){
[/phpcode]
-
Jul 14th, 2005, 01:24 AM
#5
Re: Parse errors?
Remember, this isn't VB 
As well as the two errors oceane pointed out, there is also no operator "<>" in PHP. You instead need to use "!=". If you are using an array withing an array you need to make sure you use square brakets to open and close:
PHP Code:
if($_POST[$Number] != ""){
echo($_POST['Name'][$Number]);
$Number++;
}
-
Jul 14th, 2005, 01:27 AM
#6
Re: Parse errors?
oooh I'm guilty with using <>... uhoh. gotta find and hunt those!
-
Jul 14th, 2005, 01:29 AM
#7
Re: Parse errors?
hey visualAd is this fine or is there something wrong with it as well?
PHP Code:
if ($blnRtnFlg == false){
// エラー時
return false;
}
what about the === operator? what's their difference?
-
Jul 14th, 2005, 01:33 AM
#8
Re: Parse errors?
I have yet another question
can i do this in php
if(astring != astring)
It seems that is what |23M!x is doing... checking if a string is empty.. somehow I can't find that in the dox.. so I don't do that instead just use.. strcmp...
but just wondering if that's really possible and they just did not document that in string operators part of the dox
-
Jul 14th, 2005, 01:40 AM
#9
Re: Parse errors?
if(astring != astring)
That's a constant false. You can use empty() or just compare against "".
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 14th, 2005, 01:46 AM
#10
Re: Parse errors?
Yes you can comapre two strings, the comaprison is case sensitive though. If you want a case insensitive comparision you can either convert it to lowercase/uppcase first or use stricmp().
The difference between == and === is on checks for equality and the other checks for equality and type (i.e: are they identical).
PHP Code:
$bool = true;
$int = 1;
$bool == 1; // returns true
$bool === 1; // returns false because $bool is a boolean, not an integer
$int == true; // returns true
$int === true; // returns false because $int is not a boolean its an integer
$int === 1; // returns true
$bool === true; // returns true
-
Jul 14th, 2005, 01:50 AM
#11
Re: Parse errors?
 Originally Posted by CornedBee
if(astring != astring)
That's a constant false. You can use empty() or just compare against "".
sorry wrong example. It should have been another string...
*sigh*
 Originally Posted by visualAd
Yes you can comapre two strings, the comaprison is case sensitive though. If you want a case insensitive comparision you can either convert it to lowercase/uppcase first or use stricmp().
I should have known better. and I could have saved some trouble converting some...
-
Jul 14th, 2005, 01:51 AM
#12
Thread Starter
Admodistrator
Re: Parse errors?
Almost there. thanks alot:
PHP Code:
<?php
If($_POST[send] == "1"){
$Number = 1;
While($Number < 5){
If($_POST[$Number] != ""){
echo($_POST['Name'][$Number]);
$Number++;
}
}
?>
results in a parse error also. I cannot see anything wrong at all here...
-
Jul 14th, 2005, 01:57 AM
#13
Re: Parse errors?
1.is that okey.. your send... Correct me if I'm wrong, but send there in your first if... would look for a constant variable... which is probably empty....
2.then perhaps the case of your if...
3.and where's the closing bracket for your first if?
-
Jul 14th, 2005, 01:58 AM
#14
-
Jul 14th, 2005, 01:59 AM
#15
Re: Parse errors?
I forgot to mention while too... perhaps that would cause some.
-
Jul 14th, 2005, 02:14 AM
#16
Re: Parse errors?
You haven't added the last curly bracket "}"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|