469,271 Members | 1,343 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

[function.require-once]: failed to open stream: Invalid argument

115 100+
Hi there i'm having this error
Warning: require_once(C:\wamp\www ours\connection.php) [function.require-once]: failed to open stream: Invalid argument in C:\wamp\www\tours\header.php on line 2

Fatal error: require_once() [function.require]: Failed opening required 'C:\wamp\www ours\connection.php' (include_path='.;C:\php5\pear') in C:\wamp\www\tours\header.php on line 2

could any one help me please !
this is the code of the index.php
Expand|Select|Wrap|Line Numbers
  1. <?php session_start(); ?>
  2. <table width="1000" height="377" border="1">
  3.   <tr>
  4.     <td height="56" colspan="2"><?php include("header.php"); ?></td>
  5.  
  6.   </tr>
  7.  
  8.  <tr>
  9.  <td width="215"> <?php include("left_menu.php"); ?> </td>
  10.  
  11.  <td width="769">     
  12. Bordered on one side by the Mediterranean and on the other by two parallel mountain ranges, Lebanon seems a country suspended between the sky and the sea. Despite its small area (10,452 square km), this is a land resplendent in its diverse geography, landscape, culture and history. </td></tr>  
  13. </table>
  14.  
and this one is for header.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once("C:\wamp\www\tours\connection.php");
  3. Database::connect();
  4. ?>
  5. <?php
  6. if($_SESSION[user_id]){ ?>
  7.     <a href="logout.php">logout</a>
  8.  
  9. <?php    }
  10.     else{
  11.  
  12. ?>
  13.  
  14.  
  15. <form name="login" action="">
  16.  
  17. <table><tr><td width="714">
  18. <table >
  19. <tr><td>Email</td><td><input type="text"  name="email"/></td></tr>
  20. <tr><td>Password</td><td><input type="password" name="password" /></td></tr>
  21. <tr><td colspan="2"><input type="submit" value="Login" /> </td></tr>
  22. </table>
  23.  
  24. </td>
  25. <td width="161">
  26. Not a Member? <a href="register.php">Register</a>
  27.  
  28. </td>
  29.  
  30. </tr></table>
  31.  
  32. </form> 
  33. <?php } ?>
Aug 24 '10 #1
10 8498
TheServant
1,168 Expert 1GB
I found a similar problem with google:
If you get "failed to open stream" although you are sure your include_path is correct, check your open_basedir setting.
I spent 2 hours trying to figure out why although my inclusion path was good, php kept sending me the "failed to open" error.
It was simply because my included directory was outside the scope of the open_basedir which blocks php from accessing file outside you root directory(usually).
I think the error you send the "open_basedir restriction in effect" in this case.
Try remove "C:\wamp" and turn your \ into /:
Expand|Select|Wrap|Line Numbers
  1. require_once("/www/tours/connection.php");
Aug 24 '10 #2
hannoudw
115 100+
I removed all the C:\
Now i'm getting this error
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\wamp\www\tours\DataMgmt\DbMgmt.php on line 6
Aug 24 '10 #3
zorgi
431 Expert 256MB
If the string is enclosed in double-quotes (") than "\t" becomes horizontal tab. You have this:
Expand|Select|Wrap|Line Numbers
  1. require_once("C:\wamp\www\tours\connection.php");
Notice: \tours in your code.

Can you give us code for DbMgmt.php near and around line 6?
Aug 24 '10 #4
hannoudw
115 100+
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once("connection.php");
  3. Class UserDb {
  4.  
  5.     private static $lastresult;
  6.                 Database::connect();
  7.     static public function checkUserID($usermail, &$fullname) {
  8.         $sql    = "SELECT full_name FROM users WHERE user_id = '".$usermail."'";
  9.         $result = mysql_query($sql, Database::getLink());
  10.  
  11.         if (!$result) {
  12.             echo "Erreur DB, impossible d'effectuer une requête\n";
  13.             echo 'Erreur MySQL : ' . mysql_error();
  14.             exit;
  15.         }
  16.  
  17.         $row = mysql_fetch_assoc($result);
  18.         if ($row){
  19.             $firstname   = $row['full_name'];
  20.              $trouve = true; 
  21.         } else {
  22.             $trouve = false;
  23.         }
  24.         mysql_free_result($result);
  25.         unset ($sql);
  26.         return $trouve;
  27.     }
  28. }
  29. ?>
  30.  
Aug 25 '10 #5
zorgi
431 Expert 256MB
Move
Expand|Select|Wrap|Line Numbers
  1.  Database::connect();
  2.  
inside the function.
Aug 25 '10 #6
Dormilich
8,651 Expert Mod 8TB
note: your Query is prone to SQL Injection. you need at least mysql_real_escape_string() to sanitize your input data.
Aug 25 '10 #7
hannoudw
115 100+
@Dormilich
What do you mean by that ? I didn't get your point ...

@zorgi
I removed the Database::connect(); and now i'm getting this:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\tours\DataMgmt\DbMgmt.php on line 9
Erreur DB, impossible d'effectuer une requête Erreur MySQL :
Aug 25 '10 #8
Dormilich
8,651 Expert Mod 8TB
What do you mean by that ? I didn't get your point ...
an illustrated example

I removed the Database::connect();
Zorgi didn’t say you should remove that line, he said you should move it inside the function body (line #8)
Aug 25 '10 #9
hannoudw
115 100+
@Dormilich
I read in the example that : (Do not create SQL statements that include outside data).
But how can i create the checkUserID function if i don't user the outside data ??
Aug 25 '10 #10
Dormilich
8,651 Expert Mod 8TB
the answer is given in the next line:
Use parameterized SQL calls
how to do that is also shown on that page. what a parameterized SQL call (aka Prepared Satement) is, is explained in the Wikipedia article about SQL injection (english) or this Wikipedia article (german).
Aug 25 '10 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Dov P | last post: by
12 posts views Thread by Bill Pursell | last post: by
7 posts views Thread by Bunty | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.