SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse Error Confusion about Braces {}?

    I keep getting this parse error

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/sites/waphoo.net/public_html/classes/tools.class.php on line 8
    I'm unsure why as the braces seem to be fine in the tools.class.php?

    Any advice?

    Thanks

    PHP Code:
    <?php
    require_once('config.php');


    class 
    Tools

    {
        private 
    $mMysqli;
        
        
    //constructor opens database connection
        
        
    function __construct() {
        
        
    $this->mMysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORDDB_DATABASE);
        
        }
        
        
    //destructor closes database connection
        
        
    function __destruct() {
        
        
    $this->mMysqli->close();
        
        }
        
        
        
    /*
        * Function registers users values into database and sends off 
        * an email to both the user and Core Telecom
        */
        
    public function register($name$house_number$street$town$city$postcode$country$telephone$mobile$email)
        {
        
        
    $query $this->mMysqli->query("INSERT into requests VALUES (NULL,'$telephone', '$mobile' , '$email' , 'NULL', '$name','$house_number' , '$street', '$town', '$city', '$postcode', '$country')");
        
    $this->sendCoreEmail($email$name);
        
    $this->sendUserEmail($email$name);
        return 
    '../index.html';
        
        
        }
        
        
        
        
        private function 
    sendCoreEmail($email$name)
        {
        
        
    $sender 'Waphoo';
        
    $time_of_enquiry date('r');
        
    $recipient 'martinsandhu@gmail.com';
        
    $headers "MIME-Version: 1.0\n";
        
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
        
    $headers .= "X-Mailer: php\n";
        
    $headers .= 'From: IPI <'.$sender.'>';
        
    $subject "Waphoo -  New Number Request";
        
    $mail '
        
        A new user has requested for a number to be mapped at waphoo.
        
        Name: $name
        Email: $email
        
        To view information and send this user a number. Login to the Waphoo Control Panel.
        
        http://www.waphoo.net/admin/
        
                
        
        Regards,
        Waphoo 
            
                
                '
    ;
                
                
    $result mail($recipient$subject$mail$headers); 
        
        
        
        }
        
        
        
        
        private function 
    sendUserEmail($email$name)
        {
        
        
    $sender 'Waphoo';
        
    $time_of_enquiry date('r');
        
    $recipient $email;
        
    $headers "MIME-Version: 1.0\n";
        
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
        
    $headers .= "X-Mailer: php\n";
        
    $headers .= 'From: IPI <'.$sender.'>';
        
    $subject "Waphoo -  Your New Number Request";
        
    $mail '
        
        Hello '
    .$name.'
        
        Thanks for requesting your own personal international follow me telephone number.
        
        A member of our team will be in touch within the next 24 hours to guide you through the setup and your number.
                
        
        Regards,
        Waphoo 
            
                
                '
    ;
                
                
    $result mail($recipient$subject$mail$headers); 
        
        
        
        }
    }

    ?>
    Register.php

    PHP Code:
    <?php

    require_once('classes/tools.class.php');

    $name $_POST['name'];
    $house_number $_POST['house_number'];
    $street $_POST['street'];
    $town $_POST['town'];
    $mobile $_POST['mobile'];
    $city $_POST['city'];
    $country $_POST['country'];
    $telephone $_POST['telephone'];
    $email $_POST['email'];

    $tools = new Tools();

    $tools->register($name$house_number$street$town$city$postcode$country$telephone$mobile$email);



    ?>

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure that you are using PHP 5.0 or upper version to use __construct() as a constructor??
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You could be right there Rajug, maybe its not recognising the PHP5 keyword "Private", and as you say won't know what to do with __construct() ...

  4. #4
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks that resolves that problem.

    However i'm having trouble with script not recognising my DB_HOST.

    I keep getting this error and am unable to resolve it.

    ERRNO:, 8 TEXT : Use of undefined constant DB_HOST - assumed 'DB_HOST' LOCATION: /home/sites/waphoo.net/public_html/classes/tools.class.php, line 14
    MY Config File seems fine.
    PHP Code:
    <?

    //define database connection values

    define('DB_HOST''localhost');
    define('DB_USER''*****');
    define('DB_PASSWORD''******');
    define('DB_DATABASE''*****');



    ?>

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If you are using this script on a PHP4 server, then it doesn't know what to do with mysqli - its just not installed.

    What version of PHP are you using this to test on?

  6. #6
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm using PHP5.

    You can see the settings at

    www.waphoo.net/info.php

  7. #7
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK did you try putting double quotes like this:
    Code php:
    define("DB_HOST", 'localhost');
    define("DB_USER", '*****');
    define("DB_PASSWORD", '******');
    define("DB_DATABASE", '*****');
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  8. #8
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that but that doesn't seem to get rid of that error.

    Any ideas what else could be causing it?

    Thanks

  9. #9
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And even you try putting all the constants together in a file? Also try to put the CONSTANT as well as the Value inside the double quotes? I had really the same problem before and it was solved with something like that putting double quotes.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  10. #10
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    change <? to <?php

    Using double quotes over single quotes is not the solution.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

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