Bojak Posted March 14, 2014 Share Posted March 14, 2014 <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php class DB { private static $_instance = null; private $_pdo, $_query, $_error = false, $_results, $_count = 0; private function __construct() { try { $this->_pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname='. $config::get('mysql/db'),'config::get(mysql/username','config::get(mysql/password'); } catch(PDOException $e) { die($e-getMessage()); } } } public static function getInstance() { if(!isset(self::$_instance) { self:$_instance = new DB(); } } } return self:$_instance; ?> </body> </html> getting errors on line 32, 34, 41 and i dont understand why. maybe ive missed a bracket but i have checked them a few times. any suggestions? thanks! oh, i have more files since i am trying to make it PDO but i thought you would only want to see the file in which the error occured. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/ Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 Why didn't you show us the error messages? Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472627 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 because i dont have it on a localhost at the moment. i just saw the error in dreamweaver and i cant figure it out. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472629 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 ( ! ) Fatal error: require_once(): Failed opening required 'classes/Sanitize.php' (include_path='.;C:\php\pear') in C:\wamp\www\loginsystem\Core\Init.php on line 38 ( ! ) Warning: require_once(classes/Sanitize.php): failed to open stream: No such file or directory in C:\wamp\www\loginsystem\Core\Init.php on line 38 i get that from my localhost Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472631 Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 WHAT is the error? You expect us to guess what it is? And which lines are those numbers? Suggestion? Define your class outside of your html. It will make it easier to read and debug Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472633 Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 So - now you know what your problem is. Can't find a script that you want to include Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472635 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 i fixed the missing file issue. although dreamweaver still says i have errors on on line 32, 34, 41 in the DB.php file and i posted the code above. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472641 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 i havent used any html. im currently following a tutorial. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472642 Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 Your php code is buried in the middle of html. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472643 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 ah so just remove the tags? Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472644 Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 Did your tutorial tell you to put them there? Interesting that you are following a beginner's(?) PHP tutorial and it starts out with you creating a class (for an un-necessary purpose btw) and you don't even know html yet. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472645 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 dont assume i dont know html. i do know html. this is a beginners tutorial for PDO and OOP. after taking out the html tags the index.php is blank when looking at it in a web browser. but dream weaver says i have errors on 24, 26, 33. blame dreamweaver for not being specific enough. <?php class DB { private static $_instance = null; private $_pdo, $_query, $_error = false, $_results, $_count = 0; private function __construct() { try { $this->_pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname='. $config::get('mysql/db'),'config::get(mysql/username','config::get(mysql/password'); } catch(PDOException $e) { die($e-getMessage()); } } } public static function getInstance() { if(!isset(self::$_instance) { self:$_instance = new DB(); } } } return self:$_instance; ?> Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472647 Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 Sorry - can't help you. Good luck. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472649 Share on other sites More sharing options...
Bojak Posted March 14, 2014 Author Share Posted March 14, 2014 i figured out line 33 issue. trying to figure out 24 and 26. Link to comment https://forums.phpfreaks.com/topic/286975-getting-4-errors-when-creating-this-pdo-wrapper/#findComment-1472651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.