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

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.

post some code so we can see what your doing.

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.


<?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>
 
      ";

      ?>

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

You need to encase the include file for the OR


include '/public_html/config.php' or die('Error connecting!');

should be


(include '/public_html/config.php') OR die('Error connecting!');

When you paste code onto the forum be sure to include it inside the

 tags for better readability :)

Notice I was questioning that… I’d have to see the config.php file, but I doubt it’s using the return mechanism.

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.

Or use CODE if you can’t stand the acid trip color syntax garbage that makes it HARDER to read.

Nope, they are in the right place, go try it yourself :wink:


<?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 
(include'foo') OR die ("bar"); 
?> 
 

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.

this script
contains the 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
echo "first line of code before include <br />";
(include 'test3.php') OR die ("error");
echo 'line of code after include';
?>

convinced :wink:

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)

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.

Cheers :stuck_out_tongue: works now!