xXx_Hobbes_xXx Posted March 30, 2008 Share Posted March 30, 2008 I'm trying to learn PHP, and have boughten a book found @ http://apress.com/book/view/9781590598641 I'm receiving this error message when trying to load my page Parse error: syntax error, unexpected T_REQUIRE_ONCE in C:\tshirtshop\index.php on line 6 Line 6 of my index.php says the following: require_once PRESENTATION_DIR . 'application.php'; Have I mistyped something? Am I even in the correct forum to ask? Thanks ~disgruntle n00b~ Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/ Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 Post the lines before the require_once line you most probably missing a semi-colon at the end of a line. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504768 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 <?php // Include utility files require_once 'include/config.php' // Load the application page template require_once PRESENTATION_DIR . 'application.php'; // Load Smarty template file $application = new Application(); // Display the page $applcation->display('store_front.tpl'); ?> I was indeed missing a semicolon at the top, but when I added it and ran the page again, I got this new message. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\tshirtshop\include\config.php on line 5 I'm looking now into the config.php file Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504781 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Boy, I guess you can't make any errors in typing this stuff. That'll keep me on my toes. I need to try to get this thing running, so I hope there's someone out there willing to help me on a Sunday morning. Parse error: syntax error, unexpected ';' in C:\tshirtshop\include\config.php on line 5 is the message I'm getting and that config.php file looks like this: <?php // SITE_ROOT contains the full path to the tshirt folder define('SITE_ROOT', dirname(dirname(_FILE_))); // Application directories define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'; define('BUSINESS_DIR', SITE_ROOT . '/business/'); // Settings needed to configure the Smarty template engine define('SMARTY_DIR', SITE_ROOT . '/lib/smarty/'); define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates'); define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c'); define('CONFIG_DIR', SITE_ROOT . '/include/configs'); ?> thanks again guys Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504795 Share on other sites More sharing options...
trq Posted March 30, 2008 Share Posted March 30, 2008 define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'; Should be... define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'); Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504797 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 The reason for the error in config.php is becuase your parenthesis '(' and ')' don't match up on line 5: define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'; Notice you dont have a closing brace at the end of that line, it should be: define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'); As for the error in index.php, line 3 has missing semi-colon at the end: require_once 'include/config.php' Line 3 should be: require_once 'include/config.php'; These are very basic syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504804 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Okay, thanks a lot guys. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504806 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Okay, now that all of those simple typing errors have been fixed, I'm glaring now at a screen that shows the following messages. Warning: require_once(SITE_ROOT/presentation/application.php) [function.require-once]: failed to open stream: No such file or directory in C:\tshirtshop\index.php on line 6 Fatal error: require_once() [function.require]: Failed opening required 'SITE_ROOT/presentation/application.php' (include_path='.;C:\xampp\php\pear\') in C:\tshirtshop\index.php on line 6 I've made sure that these files do exist in their correct folder and such, but then again, I'm not even sure what this error message is telling me. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504815 Share on other sites More sharing options...
lewis987 Posted March 30, 2008 Share Posted March 30, 2008 your trying to include a file under this: SITE_ROOT (Folder)/presentation/application.php Try: require_once("presentation/application.php"); instead.. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504821 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks for the suggestion, but I was only awarded with this new error: Warning: require_once(SITE_ROOT/lib/smarty/Smarty.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\tshirtshop\presentation\application.php on line 3 Fatal error: require_once() [function.require]: Failed opening required 'SITE_ROOT/lib/smarty/Smarty.class.php' (include_path='.;C:\xampp\php\pear\') in C:\tshirtshop\presentation\application.php on line 3 Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504825 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 I suggest you to define a constant called SITE_ROOT, like so: define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); And that line before line 3 in include/config.php That should sort the errors out. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504832 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 thanks, but that doesn't seem to help. I don't know what the hell i'm doing here, none of this makes any sense. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504836 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 All this should be explained in the book. Did you try my suggestion, I'll retype it so its more clear. Add the following code before line 3 in include/config.php define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); That should sort the errors out. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504845 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Yes I tried it, excuse my frustration. My book doesn't give out error help, it figures that everything is up and running like it should be; for a book designed for beginners that can make one irrate. Here's what I got in my config.php file <?php // SITE_ROOT contains the full path to the tshirt folder define('SITE_ROOT', dirname(dirname(_FILE_))); // Application directories define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'); define('BUSINESS_DIR', SITE_ROOT . '/business/'); // Settings needed to configure the Smarty template engine define('SMARTY_DIR', SITE_ROOT . '/lib/smarty/'); define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates'); define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c'); define('CONFIG_DIR', SITE_ROOT . '/include/configs'); ?> Now adding that line of yours into the third line would make it like this, right? <?php // SITE_ROOT contains the full path to the tshirt folder define('SITE_ROOT', dirname(dirname(_FILE_))); define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); // Application directories define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'); define('BUSINESS_DIR', SITE_ROOT . '/business/'); // Settings needed to configure the Smarty template engine define('SMARTY_DIR', SITE_ROOT . '/lib/smarty/'); define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates'); define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c'); define('CONFIG_DIR', SITE_ROOT . '/include/configs'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504852 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 Yes thats correct. Does it work? Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504859 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 No, the error hasn't changed. How do you put the code in a quote box like that in this forum? Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504861 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 No, the error hasn't changed. Can you attach your php scripts here for me to download so I can review them How do you put the code in a quote box like that in this forum? To add a code box, wrap your code in code tags ( , eg: your code here will produce your code here Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504881 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks for the info. Here's the entire folder that I have http://premium.fileden.com/premium/2008/3/3/1794896/tshirtshop.rar Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504903 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 Try: http://homepage.ntlworld.com/cshepwood/tshirtshop.rar Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504924 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 Fatal error: Smarty error: [in C:\tshirtshop/presentation/templates/store_front.tpl line 7]: syntax error: unrecognized tag: #site_title (Smarty_Compiler.class.php, line 446) in C:\tshirtshop\libs\smarty\Smarty.class.php on line 1092 Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504927 Share on other sites More sharing options...
$username Posted March 30, 2008 Share Posted March 30, 2008 Hey xXx_Hobbes_xXx, The best thing to do with errors that you get when testing code is to google them. You can usually see why the error is shown. And it will help you understand why you get these errors. Another place that is great is the PHP manual http://www.php.net/manual/en/, they post code to help you get a better understanding. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504932 Share on other sites More sharing options...
wildteen88 Posted March 30, 2008 Share Posted March 30, 2008 You'll need to read your book further as more code is required for it to parse the template, store_front.tpl Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504936 Share on other sites More sharing options...
xXx_Hobbes_xXx Posted March 30, 2008 Author Share Posted March 30, 2008 That's my problem. They show me a picture of their results displaying in a browser. I can't move ahead until I replicate what they have. Quote Link to comment https://forums.phpfreaks.com/topic/98635-beginning-struggling-with-code/#findComment-504941 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.