Results 1 to 16 of 16

Thread: Parse errors?

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    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?

  2. #2
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    u mistook the "["... make it "."

    if you wanted to concatenate 'Name' with $ number... and get the result from post

  3. #3
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    also there is not closing ";" on $number++

  4. #4
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    also where is the closing for this if?

    [phpcode]
    If($_POST[send] == "1"){
    [/phpcode]

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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++; 

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    oooh I'm guilty with using <>... uhoh. gotta find and hunt those!

  7. #7
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    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?

  8. #8
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    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

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    Quote 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*

    Quote 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...

  12. #12

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    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...

  13. #13
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    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?

  14. #14
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    $_POST[send]

  15. #15
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Parse errors?

    I forgot to mention while too... perhaps that would cause some.

  16. #16
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Parse errors?

    You haven't added the last curly bracket "}"
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width