unexpected T_VARIABLE, expecting '{'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kilo
    New Member
    • Jul 2007
    • 7

    unexpected T_VARIABLE, expecting '{'

    Someone please see what the problem is.. I have getting an error: Parse error: syntax error, unexpected T_VARIABLE, expecting '{' in /customers/test-dig.dk/test-dig.dk/httpd.www/database.inc.ph p on line 3

    my php codes are:

    [CODE=php] <?
    function connectDatabase ()
    $connect=mysql_ connect("test_d ig_dk", "test_dig_d k", "myusercode ");
    $select=mysql_s elect_db("ib",$ connect);
    if(!$connect || !$select)
    {
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Fehler beim Verbinden mit der Datenbank</title>
    </head>
    <body>
    <p>Es ist beim Verbinden mit der Datenbank ein Fehler aufgetreten!</p>
    </body>
    </html>
    <?
    exit();
    }
    }
    ?>
    [/CODE]
    Last edited by ak1dnar; Jul 10 '07, 02:45 PM. Reason: Added [CODE] tags
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Hi kilo,
    Welcome to TSDN.

    Mr.Php is expecting '{'
    So put it there as he said.

    [CODE=php]
    function connectDatabase ()
    {
    [/CODE]

    I have some doubts with your script anyway. Are you trying to connect to mySQL DB?

    Thanks,
    -Ajaxrand

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      This might usefull to you, for your next post.
      [code] tags

      This time I made the job for you! :)

      Thanks!
      -Ajaxrand

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'please help' actually get FEWER responses?).

        Comment

        • kilo
          New Member
          • Jul 2007
          • 7

          #5
          That did help.. { ??... Thank you very much.

          Comment

          • kilo
            New Member
            • Jul 2007
            • 7

            #6
            Originally posted by ajaxrand
            Hi kilo,
            Welcome to TSDN.

            Mr.Php is expecting '{'
            So put it there as he said.

            [CODE=php]
            function connectDatabase ()
            {
            [/CODE]

            I have some doubts with your script anyway. Are you trying to connect to mySQL DB?

            Thanks,
            -Ajaxrand
            Hi ajaxrand. Yes?? I think so...
            It's a program that I payed for, to help people to read and write Danish. the program should make the dictations and save it to a database, were people can
            load them. The main frame of the php is database.inc.ph p were all php tools use to make a connections to DB to save and upload...
            If you can make this happen that all my php's are working. I have no problem discuse your payment for your help.

            Comment

            • ak1dnar
              Recognized Expert Top Contributor
              • Jan 2007
              • 1584

              #7
              Originally posted by kilo
              Hi ajaxrand. Yes?? I think so...
              It's a program that I payed for, to help people to read and write Danish. the program should make the dictations and save it to a database, were people can
              load them. The main frame of the php is database.inc.ph p were all php tools use to make a connections to DB to save and upload...
              If you can make this happen that all my php's are working. I have no problem discuse your payment for your help.
              Hi Kilo,

              The Scripts Developer Network is a free forum and Community members are ready to help you Free of Charge.

              If you paid for the softtware tool you have the rights to fix it up from themselves.

              Any way your Problem is still unclear for me.What is not working part of your script.

              Thanks :)

              Comment

              • kilo
                New Member
                • Jul 2007
                • 7

                #8
                I having small proplems. I think. I've getting some errors 3 at all....

                If we can take one at the time.

                One of them are: Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in /customers/test-dig.dk/test-dig.dk/httpd.www/ib/select_audio.ph p on line 27

                The php code are:

                [code=php]
                <?
                require("databa se.inc.php");
                { connectDatabase ();
                ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                <title>V&aelig; lg lyd til <?=$_POST['title']?></title>
                <link href="style.css " rel="stylesheet " type="text/css" />
                </head>

                <body>
                <? if(file_exists( "text/".$_POST['title'].".txt")) {
                ?>
                <h1>V&aelig;l g lyd</h1>
                <h3 style="color:#C C3333">Pas p&aring;! Der findes allerede et diktat med denne titel.<br />
                Hvis du er ved at lave et nyt diktat, burde du g&aring; <a href="javascrip t:history.back( )">tilbage</a> og v&aelig;lge en anden titel.
                G&oslash;r du ikke det, bliver diktatet med titelen &quot;<?=$_P OST['title']?>&quot; erstattet med dette diktat her!</h3>
                <?
                }
                ?>
                <form enctype="multip art/form-data" action="save_di ct.php" method="post">
                <input type="hidden" name="MAX_FILE_ SIZE" value="500000" />
                <table border="0">
                <?
                $result=mysql_q uery("SELECT word FROM repository;");
                while($entry=my sql_fetch_array ($result)) {
                $repository[]=$entry[0];
                }
                $word_start=0;
                $word_stop=0;
                $open=false;
                $words=array();
                $content=$_POST['content'];
                for($i=0;$i<str len($content);$ i++) {
                if(substr($cont ent,$i,1)=="<" && !$open) {
                $word_start=$i+ 1;
                $open=true;
                }
                elseif(substr($ content,$i,1)== ">" && $open) {
                $word_stop=$i;
                $word=substr($c ontent,$word_st art,$word_stop-$word_start);
                if(!in_array($w ord,$repository )) {
                $words[]=$word;
                ?>
                <tr>
                <td><?=$word? ></td>
                <td><input type="file" name="<?=$word? >" /></td>
                </tr>
                <?
                }
                $open=false;
                }
                }
                ?>
                </table>
                <input type="hidden" name="words" value="<? echo implode(";",$wo rds); ?>" />
                <input type="hidden" name="content" value="<?=$_POS T['content']?>" />
                <input type="hidden" name="title" value="<?=$_POS T['title']?>" />
                <input type="submit" value="Upload &amp; gem" />
                </form>
                </body>
                </html>[/code]

                [Please use CODE tags when posting source code. Thanks! --pbmods]

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  kilo, use CODE tags around your code.

                  Review the REPLY GUIDELINES on the right next time you post.

                  Thanks!

                  MODERATOR

                  Comment

                  • kilo
                    New Member
                    • Jul 2007
                    • 7

                    #10
                    OK. I get it now

                    I have spoking to the company and it has been shout down. It's only one man sitting there.. what a shame..
                    I hope so much that you can help me through this..

                    Can you see what the following error mains:

                    Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in /customers/test-dig.dk/test-dig.dk/httpd.www/ib/select_audio.ph p on line 27

                    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /customers/test-dig.dk/test-dig.dk/httpd.www/ib/select_audio.ph p on line 43

                    PHP code:

                    [code=php]
                    <?
                    require("databa se.inc.php");
                    connectDatabase ();
                    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                    <title>V&aelig; lg lyd til <?=$_POST['title']?></title>
                    <link href="style.css " rel="stylesheet " type="text/css" />
                    </head>

                    <body>
                    <? if(file_exists( "text/".$_POST['title'].".txt")) {
                    ?>
                    <h1>V&aelig;l g lyd</h1>
                    <h3 style="color:#C C3333">Pas p&aring;! Der findes allerede et diktat med denne titel.<br />
                    Hvis du er ved at lave et nyt diktat, burde du g&aring; <a href="javascrip t:history.back( )">tilbage</a> og v&aelig;lge en anden titel.
                    G&oslash;r du ikke det, bliver diktatet med titelen &quot;<?=$_P OST['title']?>&quot; erstattet med dette diktat her!</h3>
                    <?
                    }
                    ?>
                    <form enctype="multip art/form-data" action="save_di ct.php" method="post">
                    <input type="hidden" name="MAX_FILE_ SIZE" value="500000" />
                    <table border="0">
                    <?
                    $result=mysql_q uery("SELECT word FROM repository;");
                    while($entry=my sql_fetch_array ($result)) {
                    $repository[]=$entry[0];
                    }
                    $word_start=0;
                    $word_stop=0;
                    $open=false;
                    $words=array();
                    $content=$_POST['content'];
                    for($i=0;$i<str len($content);$ i++) {
                    if(substr($cont ent,$i,1)=="<" && !$open) {
                    $word_start=$i+ 1;
                    $open=true;
                    }
                    elseif(substr($ content,$i,1)== ">" && $open) {
                    $word_stop=$i;
                    $word=substr($c ontent,$word_st art,$word_stop-$word_start);
                    if(!in_array($w ord,$repository )) {
                    $words[]=$word;
                    ?>
                    <tr>
                    <td><?=$word? ></td>
                    <td><input type="file" name="<?=$word? >" /></td>
                    </tr>
                    <?
                    }
                    $open=false;
                    }
                    }
                    ?>
                    </table>
                    <input type="hidden" name="words" value="<? echo implode(";",$wo rds); ?>" />
                    <input type="hidden" name="content" value="<?=$_POS T['content']?>" />
                    <input type="hidden" name="title" value="<?=$_POS T['title']?>" />
                    <input type="submit" value="Upload &amp; gem" />
                    </form>
                    </body>
                    </html>
                    [/CODE]

                    Comment

                    • pbmods
                      Recognized Expert Expert
                      • Apr 2007
                      • 5821

                      #11
                      Heya, Kilo.

                      On line 27, right after you mysql_query(), add this code:
                      [code=php]
                      if(! $result)
                      exit(mysql_erro r());
                      [/code]

                      Comment

                      Working...