472,371 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

[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>
  6.   </tr>
  8.  <tr>
  9.  <td width="215"> <?php include("left_menu.php"); ?> </td>
  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>
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>
  9. <?php    }
  10.     else{
  12. ?>
  15. <form name="login" action="">
  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>
  24. </td>
  25. <td width="161">
  26. Not a Member? <a href="register.php">Register</a>
  28. </td>
  30. </tr></table>
  32. </form> 
  33. <?php } ?>
Aug 24 '10 #1
10 8843
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
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
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
115 100+
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once("connection.php");
  3. Class UserDb {
  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());
  11.         if (!$result) {
  12.             echo "Erreur DB, impossible d'effectuer une requête\n";
  13.             echo 'Erreur MySQL : ' . mysql_error();
  14.             exit;
  15.         }
  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. ?>
Aug 25 '10 #5
431 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1.  Database::connect();
inside the function.
Aug 25 '10 #6
8,658 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
115 100+
What do you mean by that ? I didn't get your point ...

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
8,658 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
115 100+
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
8,658 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

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

Similar topics

by: Keiron Waites | last post by:
Hi, I include the following function: <?php function login($members_only) { if (isset($_COOKIE)) { $login = explode("|split|",$_COOKIE); $login =...
by: gustav04 | last post by:
hi all i have a question: what is the difference between a c-function and an c++ class method (both do exactly the same thing). lets say, i have a function called print2std() and a class...
by: LineVoltageHalogen | last post by:
I have many stored procs in my database and I can call them just by their name uspMyProc with success always. However, I just created a user function ufnMyFunction as the same user that I created...
by: gamja | last post by:
Hi all. This is my first post on this group. Nice to meet you, cool guys~! I'm on system programming on various embedded systems and understand very well the byte alignment issues. When I write...
by: Dov P | last post by:
hello everyone, i need to use api function named RegSetKeySecurity in my C# program. This function require ADVAPI32.DLL, but i cannot add this reference. I tried to use Microsoft.Win32.Registry...
by: Bill Pursell | last post by:
The following code generates a compiler warning when compiled with gcc -pedantic: typedef (*FUNC)(int); FUNC f; void * get_f(void) { return &f;
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
by: lowbotpro | last post by:
Hi, I am not very good at PHP and am trying to install a script but I have this problem that I just can't figure out... Code snippet: <?php // UTF-8 helper functions...
by: sumanthsclsdc | last post by:
Hello friends, I have a problem, I implemented a class which uses tkinter and displays the window as required, the class will create a window with listbox and inserts some items into it, I...
by: Bunty | last post by:
When we want to call another file at that time we can use both include and require.Please tell me what's the difference between them?
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.