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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hannoudw
    New Member
    • Aug 2010
    • 115

    #1

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

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

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

    could any one help me please !
    this is the code of the index.php
    Code:
    <?php session_start(); ?>
    <table width="1000" height="377" border="1">
      <tr>
        <td height="56" colspan="2"><?php include("header.php"); ?></td>
     
      </tr>
      
     <tr>
     <td width="215"> <?php include("left_menu.php"); ?> </td>
     
     <td width="769"> 	
    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>  
    </table>
    and this one is for header.php
    Code:
    <?php
    require_once("C:\wamp\www\tours\connection.php");
    Database::connect();
    ?>
    <?php
    if($_SESSION[user_id]){ ?>
    	<a href="logout.php">logout</a>
    	
    <?php	}
    	else{
    
    ?>
    
    
    <form name="login" action="">
    
    <table><tr><td width="714">
    <table >
    <tr><td>Email</td><td><input type="text"  name="email"/></td></tr>
    <tr><td>Password</td><td><input type="password" name="password" /></td></tr>
    <tr><td colspan="2"><input type="submit" value="Login" /> </td></tr>
    </table>
    
    </td>
    <td width="161">
    Not a Member? <a href="register.php">Register</a>
    
    </td>
    
    </tr></table>
    
    </form> 
    <?php } ?>
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    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(usual ly).
    I think the error you send the "open_based ir restriction in effect" in this case.
    Try remove "C:\wamp" and turn your \ into /:
    Code:
    require_once("/www/tours/connection.php");

    Comment

    • hannoudw
      New Member
      • Aug 2010
      • 115

      #3
      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\tou rs\DataMgmt\DbM gmt.php on line 6

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        If the string is enclosed in double-quotes (") than "\t" becomes horizontal tab. You have this:
        Code:
        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?

        Comment

        • hannoudw
          New Member
          • Aug 2010
          • 115

          #5
          Code:
          <?php
          require_once("connection.php");
          Class UserDb {
          
          	private static $lastresult;
                          Database::connect();
          	static public function checkUserID($usermail, &$fullname) {
          		$sql    = "SELECT full_name FROM users WHERE user_id = '".$usermail."'";
          		$result = mysql_query($sql, Database::getLink());
          		        
          		if (!$result) {
          		    echo "Erreur DB, impossible d'effectuer une requĂȘte\n";
          		    echo 'Erreur MySQL : ' . mysql_error();
          		    exit;
          		}
          
          		$row = mysql_fetch_assoc($result);
          		if ($row){
          			$firstname   = $row['full_name'];
          		 	$trouve = true; 
          		} else {
          			$trouve = false;
          		}
          		mysql_free_result($result);
          		unset ($sql);
          		return $trouve;
          	}
          }
          ?>

          Comment

          • zorgi
            Recognized Expert Contributor
            • Mar 2008
            • 431

            #6
            Move
            Code:
             Database::connect();
            inside the function.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              note: your Query is prone to SQL Injection. you need at least mysql_real_esca pe_string() to sanitize your input data.

              Comment

              • hannoudw
                New Member
                • Aug 2010
                • 115

                #8
                @Dormilich
                What do you mean by that ? I didn't get your point ...

                @zorgi
                I removed the Database::conne ct(); and now i'm getting this:
                Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\tou rs\DataMgmt\DbM gmt.php on line 9
                Erreur DB, impossible d'effectuer une requĂȘte Erreur MySQL :

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  What do you mean by that ? I didn't get your point ...
                  an illustrated example

                  I removed the Database::conne ct();
                  Zorgi didn’t say you should remove that line, he said you should move it inside the function body (line #8)

                  Comment

                  • hannoudw
                    New Member
                    • Aug 2010
                    • 115

                    #10
                    @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 ??

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      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).
                      Last edited by Dormilich; Aug 25 '10, 08:20 AM.

                      Comment

                      Working...