SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question HELP with an error!

    Hey. I keep getting these 2 errors with my php code.

    Warning: include(1) [function.include]: failed to open stream: No such file or directory in /home/a3362820/public_html/index.php on line 5
    Warning: include() [function.include]: Failed opening '1' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3362820/public_html/index.php on line 5

    The right file is definately in the right directory.

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'a3362820'@'localhost' (using password: NO) in /home/a3362820/public_html/index.php on line 7
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/a3362820/public_html/index.php on line 7

    Any help would be appreciated.

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    post some code so we can see what your doing.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  3. #3
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Also this might be obvious, but check your CASE... and check permissions/ownership... If the file is set to 640 root:root, www-data isn't going to be able to access it.

    But yeah, no code, we're guessing blind.

  4. #4
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

          
    echo "<h1>Blog</h1><hr>";

          include 
    '/public_html/config.php' or die('Error connecting!');
     
          
    $queryget mysql_query("SELECT * FROM blogEntries") or die('Error with query!');
     
          while (
    $row mysql_fetch_assoc($queryget))

          {
     
          
    $id $row['id'];

          
    $name $row['name'];
      
          
    $message $row['message'];
      
          
    $date $row['date'];
      
          
    $time $row['time'];
      
          }
     
          echo 
    "<hr>";
     
          echo 
    "
      
          <form action=;index.php' method='POST'>

          <table width='100%'>
      
          <tr>
     
          <td width='18%' valign='top'>
     
          Your name:
     
          </td>
      
          <td>
      
          <input type='text' name='name' maxlength='25'>
     
          </td>
     
          </tr>

          <tr>
     
          <td valign='top'>
      
          Your message:
     
          </td>

          <td>

          <textarea cols='20' rows='2' name='message maxlength='250'>

          <p>
      
          <input type='submit' name='submit' value='Post'>

          </td>

          </tr>
     
          </table>
     
          </form>
     
          "
    ;

          
    ?>
    Last edited by AnthonySterling; Mar 11, 2011 at 02:18. Reason: Addition of PHP BBTags

  5. #5
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Is that config.php in the same directory or a subdirectory of where that .php is being run?

    If so, try losing the path. \ roots it, which can often be a problem.

    just:
    include('config.php');

    when it comes to pathing, avoid making things more complex than need be -- part of why I advocate putting anything the user can call directly in root, and libraries/subroutines/etc in subdirectories, so everything points 'down tree' instead of 'up tree'.

  6. #6
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You need to encase the include file for the OR

    PHP Code:
    include '/public_html/config.php' or die('Error connecting!'); 
    should be

    PHP Code:
    (include '/public_html/config.php') OR die('Error connecting!'); 
    When you paste code onto the forum be sure to include it inside the [PHP] tags for better readability
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  7. #7
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mandes View Post
    You need to encase the include file for the OR

    PHP Code:
    include '/public_html/config.php' or die('Error connecting!'); 
    Notice I was questioning that... I'd have to see the config.php file, but I doubt it's using the return mechanism.

    Quote Originally Posted by Mandes View Post
    should be

    PHP Code:
    (include '/public_html/config.php') OR die('Error connecting!'); 
    Your opening parenthesis is in the wrong place. goes AFTER include not before it... and if you are thinking you have to wrap it to make it syntatic, that's only if it's in an if statement.

    Quote Originally Posted by Mandes View Post
    When you paste code onto the forum be sure to include it inside the [PHP] tags for better readability
    Or use CODE if you can't stand the acid trip color syntax garbage that makes it HARDER to read.

  8. #8
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    Your opening parenthesis is in the wrong place. goes AFTER include not before it...
    Nope, they are in the right place, go try it yourself

    PHP Code:
    <?php 
    include('foo') OR die ("bar"); // <- Won't work 
    (include('foo')) OR die ("bar"); // <- Works 
    ?>
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  9. #9
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mandes View Post
    Nope, they are in the right place, go try it yourself

    PHP Code:
    <?php 
    include('foo') OR die ("bar"); // <- Won't work 
    (include('foo')) OR die ("bar"); // <- Works 
    ?>
    I am sorry, look at your post Mandes, niether of those are what you suggested. Orginally you said
    PHP Code:
    <?php 
    (include'foo') OR die ("bar"); 
    ?>
    Ryan B | My Blog | Twitter

  10. #10
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Still stands, have you tried it, I did before I posted the original answer to the OP, the OR requires the whole include to be in brackets.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  11. #11
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    this script
    contains the code

    PHP Code:
    <?php
    echo "first line of code before include <br />";
    include 
    'test3.php' OR die ("error");
    echo 
    'line of code after include';
    ?>
    And

    this script
    contains the code

    PHP Code:
    <?php
    echo "first line of code before include <br />";
    (include 
    'test3.php') OR die ("error");
    echo 
    'line of code after include';
    ?>
    convinced
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  12. #12
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Odd, You'd figure with the syntax rules the latter would be invalid -- though I'd have expected the first one to ALSO be invalid. Ok, my bad.

    Though I still question the use of OR after an include; but then I don't tend to do includes that return anything as a result since that's sloppy coding from a security point of view... since then anything can just up and call that include and anything it does is global... which is why I like functions and returns from functions instead of using the return mechanism on include. (and in the case of really important stuff like SQL login info, include a mechanism so only approved files can ask for it in the first place)

  13. #13
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I agree, Id never used the OR with an include either, hence I tried it before my response.

    But it solves the problem the OP had hopefully.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  14. #14
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers :P works now!


Tags for this Thread

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
  •