jkewlo Posted July 16, 2010 Share Posted July 16, 2010 Hello I have never had this problem over the years of me programming with PHP Here is a Hierarchy of my file structure control_panel css data - config.php functions - Security.class.php - Session.class.ph img snippets - rijndael-256-bit-encryption-using-mcrypt.php index.php install.php check.php license.txt mysql.php so what I am doing is index.php has include("Security.class.php"); and in Security.class.php in security.php I have include("../data/config.php"); this causes this error Warning: include(../data/config.php) [function.include]: failed to open stream: No such file or directory in functions/Security.class.php on line 8 Warning: include() [function.include]: Failed opening '../data/config.php' for inclusion (include_path='.*REMOVED*') in functions/Security.class.php on line 8 but if I change it to /data/config it works but clearly it is in functions folder so I would have to use ../ to goto the directory. when I do get it right. it does not work in IE. This is a market targeted website so It will need to work with all browsers. I dont get why it is doing this. I have never had this problem before Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/ Share on other sites More sharing options...
AbraCadaver Posted July 16, 2010 Share Posted July 16, 2010 Paths are relative to the original file that was loaded, in this case index.php. So given that you include Security.class.php in index.php, its includes will still be relative to index.php. include("data/config.php"); Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087183 Share on other sites More sharing options...
PFMaBiSmAd Posted July 16, 2010 Share Posted July 16, 2010 It will need to work with all browsers. Php is a server-side scripting language and the include statements have nothing to do with the browser. Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087184 Share on other sites More sharing options...
jkewlo Posted July 16, 2010 Author Share Posted July 16, 2010 and here is my code <?php //Devila Security.class.php //Start Session session_start(); //Get database connection string include("../data/config.php"); //Generate Random Key's //This will be commented out as java is doing it. /*function generate_chars() { $num_chars = 32; //max length of random chars $i = 0; $my_keys = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; //keys to be chosen from $keys_length = strlen($my_keys); while($i<$num_chars) { $rand_num = mt_rand(1, $keys_length-1); $sEcCodE .= $my_keys[$rand_num]; $i++; } return $sEcCodE; } */ //Get POST data from license.php function get_Data() { $License = "../license.txt"; $File = fopen($License, 'r'); $Read = fread($File, 35); fclose($File); return $Read; } //Get the User's Name from the database using the product_key in Licnese.txt function get_Name(){ $sql="SELECT * FROM sec_code WHERE product_key='". get_Data() ."'"; $result=mysql_query($sql) or die("Error1 1". mysql_error() .""); $row = mysql_fetch_assoc($result); echo $row['name']; } //Get the User's Id from the database using the product_key in License.txt function get_Id(){ $sql="SELECT * FROM sec_code WHERE product_key='". get_Data() ."'"; $result=mysql_query($sql) or die("Error1 2". mysql_error() .""); $row = mysql_fetch_assoc($result); echo $row['id']; } ?> <?php // Devila Session.class.php //Start Session session_start(); //Get database connection string include("../data/config.php"); //Set standard User Veriables $name = mysql_real_escape_string($_POST['name']); $sid = mysql_real_escape_string($_POST['server_id']); $pkey = mysql_real_escape_string($_POST['product_key']); $email = mysql_real_escape_string($_POST['email']); //Start Strip Tags Trim then StripSlashes $sname = strip_tags(trim(stripslashes($name))); $ssid = strip_tags(trim(stripslashes($sid))); $spkey = strip_tags(trim(stripslashes($pkey))); $semail = strip_tags(trim(stripslashes($email))); //Create Sessions $_SESSION['name'] = $sname; $_SESSION['sid'] = $ssid; $_SESSION['pkey'] = $spkey; $_SESSION['email'] = $semail; //You know what this does! $sql="INSERT INTO sec_code(name, email, product_key, server_id) VALUES('". $stname ."', '". $stemail ."', '". $stpkey ."', '". $stsid ."')"; mysql_query($sql) or die("Could not send your message!". mysql_error()); $msg = "Java Application updated the database information."; echo "". $msg ."<br><a href=http://www.eve-lounge.com/DH/index.php>Click here to goto to Index page</a>"; ?> <?php //Start Session session_start(); //Get database connection string include("functions/Security.class.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Devila Project</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <!--[if lt IE 7]> <style type="text/css"> .pngfix { behavior: url(pngfix/iepngfix.htc);} .tooltip{width:200px;}; </style> <![endif]--> </head> <body> <div id="main-container"> <div class="bargain-bin"> <a href="index.php/"><img src="img/sheild..png" border="0"/></a> <h3></h3> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Devial Log in</span> </span> <span class="top-label"> <span class="label-txt">Random Quotes</span> </span> <div class="content-area"> <div class="content drag-desired"> Welcome to Devila. Please Log in below! <form name="login" method="post" action="check.php"> <table border="0" cellspacing="5" cellpadding="5"> <tr> <td><div align="right">Server Id:</div></td> <td><input name="server_id" id="server_id" type="text" value=""> (Enter Your Server Id)</td> </tr> <tr> <td><div align="right">Password:</div></td> <td><input name="sec_password" id="sec_password" type="password" value=""> (Enter Your Password)</td> </tr> <tr> <td colspan="2"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> <div class="clear"></div> </div> </div> <div class="bottom-container-border"> </div> </div> </div> <div class="bargain-bin-info"> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087186 Share on other sites More sharing options...
AbraCadaver Posted July 16, 2010 Share Posted July 16, 2010 and here is my code O.K, and I gave you the answer. Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087188 Share on other sites More sharing options...
jkewlo Posted July 16, 2010 Author Share Posted July 16, 2010 Right ok that fixed that. now I have control_panel and it is throwing the error as well I would think that //Call Function include("../functions/Security.class.php"); [\php] would work?! Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087191 Share on other sites More sharing options...
AbraCadaver Posted July 16, 2010 Share Posted July 16, 2010 No, same issue. You have loaded control_panel.php, so every include from there on is relative to control_panel.php: include("functions/Security.class.php"); Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087193 Share on other sites More sharing options...
jkewlo Posted July 16, 2010 Author Share Posted July 16, 2010 Sorry I messed up when writing that control_panel is a folder with index.php inside of it Quote Link to comment https://forums.phpfreaks.com/topic/207967-functioninclude-error/#findComment-1087206 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.