Problem in including files

Discussion in 'PHP' started by kks_krishna, May 16, 2007.

  1. #1
    HI,
    I am getting the following error when including a file.what is the probelm?

    Parse error: syntax error, unexpected T_INCLUDE, expecting T_FUNCTION in D:\xampp\htdocs\dlinks\files\UsersOperations.php on line 4
     
    kks_krishna, May 16, 2007 IP
  2. gfreeman

    gfreeman Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What's line 4 say?
     
    gfreeman, May 16, 2007 IP
  3. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Yes,, i got the solution. we cannot include a file inside class object.
     
    kks_krishna, May 16, 2007 IP
  4. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Again i got this error :
    Parse error: syntax error, unexpected T_VAR in D:\xampp\htdocs\dlinks\includes\db_details.php on line 2

    included file:
    include("../includes/db_details.php");

    content:
    <?php
    var $db_name = "xxxx";
    var $db_user = "xxx";
    var $db_pass = "xxxx";
    var $db_host = "xxxxx";
    ?>
     
    kks_krishna, May 16, 2007 IP
  5. gfreeman

    gfreeman Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Take out the "var" bits, so it reads:
    $db_name = "xxxx";
     
    gfreeman, May 16, 2007 IP
  6. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #6
    also i am getting the following error when connecting to the mysql:
    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\xampp\htdocs\dlinks\files\UsersOperations.php on line 8
     
    kks_krishna, May 16, 2007 IP
  7. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #7
    That problem is corrected . thanks for your reply.
     
    kks_krishna, May 16, 2007 IP
  8. gfreeman

    gfreeman Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The mysql_connect issue will be you providing the wrong username/password for the database you are trying to read from.

    I generally create a function that handles all the mysql stuff, and all I pass to it is the query. That way if you get errors you know that the problem is in one place.

    How are you calling the mysql_connect?
     
    gfreeman, May 16, 2007 IP
  9. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Have you ever considered, you know, sorta trying to learn PHP? There are plenty of great resources, the error messages tell you exactly what and where is wrong, and everything is extremely well documented in the PHP manual. I can understand running into a few problems but this is what, nearly your 10th topic in just a few days?? And pretty much every error you've posted is self-explanitory and/or a matter of common sense.

    You only ever need to use "var" when you're setting up class properties - and even then only if you're still on PHP4. If you just want to define those variables, you don't need var. The error message "syntax error, unexpected T_VAR" would kinda suggest that that's your problem..

    Access denied for user 'ODBC'@'localhost' (using password: NO) - so what do you think could possibly be the problem there? I'm guessing your mysql user is not "ODBC" and you do have a password - so it's not using the user/pass you're specifying. Can't say why for certain without seeing the code - if the call to mysql_connect is within another class or function, can it access the $db_ variables? You may need to set them as globals or (better) pass them as arguments to the function.
     
    rodney88, May 16, 2007 IP
  10. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #10
    Warning: mysql_connect() [function.mysql-connect]: Host 'krishna' is not allowed to connect to this MySQL server in D:\xampp\htdocs\dlinks\files\UsersOperations.php on line 8
     
    kks_krishna, May 16, 2007 IP
  11. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #11

    read php mysql and apache by Julie C. Meloni

    also, when you get an error google it.

    worked for me...er...well i kinda stopped learning for awhile but the book kicks ass
     
    Dirty-Rockstar, May 16, 2007 IP
  12. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #12
    Use Host Name as localhost This will work for you.
     
    Subikar, May 17, 2007 IP