Jump to content

Beginning, Struggling With Code


xXx_Hobbes_xXx

Recommended Posts

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~

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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');
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.