linardzb Posted January 21, 2013 Share Posted January 21, 2013 (edited) Hi, Im having a nightmare (very newbie to PHP) to display a webpge which changes the title dinamically with PHP scripts that Im sure are correct. Instead it gives me ERROR 500. As well as hosting provider is not sure if my directory structure is correct, again Im very positive it is correct, trying to sort this bugger out for ages. I will add a png file for directory overview. Can someone please have alook at this example: http://www.origin-designs.co.uk/ 1. All goes wrong when I add this script to my _header.php: <?php $objBusiness = new Business(); $business = $objBusiness->getBusiness(); ?> 2. This is Business class script: <?php class Business extends Application { private $_table = 'business'; public function getBusiness() { $sql = "SELECT * FROM `{$this->_table}` WHERE `id` = 1"; return $this->db->fetchOne($sql); } public function getVatRate() { $business = $this->getBusiness(); return $business['vat_rate']; } public function updateBusiness($vars = null) { if (!empty($vars)) { $this->db->prepareUpdate($vars); return $this->db->update($this->_table, 1); } } } will provide you with further information if needed. Many thanks. Edited January 21, 2013 by linardzb Quote Link to comment Share on other sites More sharing options...
The Letter E Posted January 22, 2013 Share Posted January 22, 2013 What error is php throwing? Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 Thanks for looking in, the problem is that PHP does not throw any error, it is just hosting internal server error. Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 I double checked the path to files, and it all seems fine. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 22, 2013 Share Posted January 22, 2013 A http 500 response code for a php produced page usually means a fatal parse or fatal runtime error. If your code works on your development system, so that we can assume that it doesn't have a fatal parse error, you are likely getting a fatal runtime error. To help debug a runtime error, add the following two lines of code, immediately after your first opening <?php tag, to see what if any php errors are occurring - ini_set("display_errors", "1"); error_reporting(-1); Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 (edited) A http 500 response code for a php produced page usually means a fatal parse or fatal runtime error. If your code works on your development system, so that we can assume that it doesn't have a fatal parse error, you are likely getting a fatal runtime error. To help debug a runtime error, add the following two lines of code, immediately after your first opening <?php tag, to see what if any php errors are occurring - ini_set("display_errors", "1"); error_reporting(-1); Sorry for dumb question, shall I throw it in index.php or _header.php ? cheers Edited January 22, 2013 by linardzb Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 Thank you PFMaBiSmAd, I tried to run the code you suggested in _header.php and index.php, seems not be working. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 22, 2013 Share Posted January 22, 2013 I don't see anything that indicates the OP's code works on a development server, it sounds like it does have a fatal parse error, which would cause ini_set to never get processed. Better to change it in the php.ini. Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 Thanks Jessica, The one option I could find out was /usr/local/php52/etc/php.ini, but it is not on my server, is it on host? Sorry for dumb question. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 22, 2013 Share Posted January 22, 2013 I don't even understand the question. Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 This is Directory access code: <?php if(!isset($_SESSION)) { session_start(); } // site domain name with http defined("SITE_URL") || define("SITE_URL", "http://".$_SERVER['SERVER_NAME']); // directory separator defined("DS") || define("DS", DIRECTORY_SEPARATOR); // root path defined("ROOT_PATH") || define("ROOT_PATH", realpath(dirname(__FILE__) . DS."..".DS)); // classes folder defined("CLASSES_DIR") || define("CLASSES_DIR", "classes"); // pages directory defined("PAGES_DIR") || define("PAGES_DIR", "pages"); // modules folder defined("MOD_DIR") || define("MOD_DIR", "mod"); // inc folder defined("INC_DIR") || define("INC_DIR", "inc"); // templates folder defined("TEMPLATE_DIR") || define("TEMPLATE_DIR", "template"); // emails path defined("EMAILS_PATH") || define("EMAILS_PATH", ROOT_PATH.DS."emails"); // catalogue images path defined("CATALOGUE_PATH") || define("CATALOGUE_PATH", ROOT_PATH.DS."media".DS."catalogue"); // add all above directories to the include path set_include_path(implode(PATH_SEPARATOR, array( realpath(ROOT_PATH.DS.CLASSES_DIR), realpath(ROOT_PATH.DS.PAGES_DIR), realpath(ROOT_PATH.DS.MOD_DIR), realpath(ROOT_PATH.DS.INC_DIR), realpath(ROOT_PATH.DS.TEMPLATE_DIR), get_include_path() ))); Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 To Jessica, Right, where do I look for the php.ini file to change it, and how do I debug that parse error? Hope it make sense now Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 22, 2013 Share Posted January 22, 2013 (edited) I would try putting the code on my laptop/desktop/whatever pc and use something like WAMP to set up a localhost to do testing, since it sounds like you're using a shared host. Edited January 22, 2013 by Jessica Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 22, 2013 Author Share Posted January 22, 2013 Thanks Jessica, thats exactly the case, trying to sort this out for ages, Cheers Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 23, 2013 Author Share Posted January 23, 2013 Hey, just got my hands on local host, and it seems that the code <?php $objBusiness = new Business(); $business = $objBusiness->getBusiness(); ?> is working, whereas on on shared hosting still not working, any thoughts? Cheers Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 23, 2013 Share Posted January 23, 2013 Find what's different between the servers. Quote Link to comment Share on other sites More sharing options...
linardzb Posted January 23, 2013 Author Share Posted January 23, 2013 Shared hosting: MySQL Server version: 5.0.92-50-log WebServer: MySQL client version: 5.1.66 which provides Info NOTE: Your PHP MySQL library version 5.1.66 differs from your MySQL server version 5.0.92. This may cause unpredictable behavior. Which I checked, and aparently it needs to updated via: yum update php Local Server: MySQL Server version: 5.5.8-log WebServer Apache/2.2.17 (Win32) PHP/5.3.5 MySQL client version: mysqlnd 5.0.7-dev - 091210 Yhank you for the help Quote Link to comment Share on other sites More sharing options...
The Letter E Posted January 26, 2013 Share Posted January 26, 2013 Have you checked to see if there is an error log on your system? Perhaps check with your hosting provider? Quote Link to comment 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.