Forum Moderators: coopster

Message Too Old, No Replies

php error

Parse error: syntax error, unexpected T_IF

         

semolinapilchard

12:45 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



hi

i am a stay at home mum so i have absolutely zilch knowledge of anything to do with web design code etc... however i have managed to make a half decent cubecart store for my business.

i have just added a mod to change the order of my categories which works perfectly - BUT i now get this error on all of my category pages:

Parse error: syntax error, unexpected T_IF in.....includes/content/viewCat.inc.php on line 1

i have cross referenced existing page with the back up i made before adding the mod but i cannot find any difference in the first 20 lines and i cant see any unclosed brackets etc..

*/if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) ¦¦ eregi(".inc.php",$_SERVER['PHP_SELF'])) {echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";exit;}if(isset($_GET['page'])){$page = treatGet($_GET['page']);} else {$page = 0;}$view_cat = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/viewCat.tpl");////////////////////////// BUILD SUB CATEGORIES////////if(isset($_GET['catId'])) {$_GET['catId'] = treatGet($_GET['catId']);// build query$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY cat_name ASC";$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY pos";// get category array in foreign innit$resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".$lang_folder."'");// query database$subCategories = "";$subCategories = $db->select($query);}if(isset($_GET['catId']) && $_GET['catId']>0 && $subCategories == TRUE) {// loop resultsfor ($i=0; $i<count($subCategories); $i++){if(is_array($resultsForeign)){for ($k=0; $k<count($resultsForeign); $k++){if($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']){$subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];
before this is just the standard cubecart info and copyright bits - would the error be in there?

thanks in advance for any help

esther

jatar_k

12:52 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld semolinapilchard,

is that the contents of viewCat.inc.php?

I am guessing the error might be trickling through to it.

what is the actual script that is including that file?
What are the few lines before the include statement?

PHP_Chimp

12:54 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is on line 1 in the includes/content/viewCat.inc.php file?
Or is that the code that you posted?

semolinapilchard

12:56 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



thanks for the replies!

the preceding code is this:
<?php/*+--------------------------------------------------------------------------¦ CubeCart v3.0.15¦ ========================================¦ by Alistair Brookbanks¦CubeCart is a Trade Mark of Devellion Limited¦ Copyright Devellion Limited 2005 - 2006. All rights reserved.¦ Devellion Limited,¦ 22 Thomas Heskin Court,¦ Station Road,¦ Bishops Stortford,¦ HERTFORDSHIRE.¦ CM23 3EE¦ UNITED KINGDOM¦ http://www.example.com¦UK Private Limited Company No. 5323904¦ ========================================¦ Web: [cubecart.com¦...] Date: Thursday, 4th January 2007¦ Email: sales (at) cubecart (dot) com¦License Type: CubeCart is NOT Open Source Software and Limitations Apply ¦ Licence Info: [cubecart.com...] --------------------------------------------------¦viewCat.inc.php¦ ========================================¦Display the Current Category+---------------------------------------------------------------- ----------

[edited by: dreamcatcher at 1:02 pm (utc) on Oct. 31, 2007]
[edit reason] Use example.com, thanks. [/edit]

PHP_Chimp

1:01 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the filename of the page where that code is coming from?

As you have an included file and the error is on that included file. So if the code you have posted is not in that included file then there is no error with the code you have posted.

Habtom

1:02 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you have missed a few closing brackets at the end of the script. Infact four closing brackets if I am not mistaken.

Here is the last few lines of the code you have with the brackets:


if(isset($_GET['catId']) && $_GET['catId']>0 && $subCategories == TRUE) {
// loop results
for ($i=0; $i<count($subCategories); $i++){
if(is_array($resultsForeign)){
for ($k=0; $k<count($resultsForeign); $k++){
if($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']){
$subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];
}
}
}
}

[edited by: Habtom at 1:03 pm (utc) on Oct. 31, 2007]

semolinapilchard

1:05 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



filename is: home/xvuqvuh/public_html/store/includes/content/viewCat.inc.php

and those lines of code are the first lines from that file.

i will go and see if putting in those brackets helps

semolinapilchard

1:33 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



thanks habtom

the brackets are in the code i didnt copy enough - with it saying line 1 i thought it would be nearer the top so havent given all of the code.

nobody can see any of my products as the error comes up when anyone clicks on any of the cats!

jatar_k

1:45 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



does that file actually look like that? with no returns in it?

or was that a pasting issue?

if it actually looks like that then you need to add carriage returns and re save it, then see if it works

semolinapilchard

1:48 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



thanks jatar

thats how the file looks - where do i put in the returns?

jatar_k

1:52 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



something like this

<?php

/*
+--------------------------------------------------------------------------
¦ CubeCart v3.0.15
¦ ========================================
¦ by Alistair Brookbanks
¦CubeCart is a Trade Mark of Devellion Limited
¦ Copyright Devellion Limited 2005 - 2006. All rights reserved.
¦ Devellion Limited,
¦ 22 Thomas Heskin Court,
¦ Station Road,
¦ Bishops Stortford,
¦ HERTFORDSHIRE.
¦ CM23 3EE
¦ UNITED KINGDOM
¦ http://www.example.com
¦UK Private Limited Company No. 5323904
¦ ========================================
¦ Web: [cubecart.com...]
¦ Date: Thursday, 4th January 2007
¦ Email: sales (at) cubecart (dot) com
¦License Type: CubeCart is NOT Open Source Software and Limitations Apply
¦ Licence Info: [cubecart.com...]
+------------------------
--------------------------------------------------
¦viewCat.inc.php
¦========================================
¦Display the Current Category
+----------------------------------------------------------------
----------
*/

if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) ¦¦ eregi(".inc.php",$_SERVER['PHP_SELF'])) {
echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
exit;
}

if(isset($_GET['page'])){
$page = treatGet($_GET['page']);
} else {
$page = 0;
}

$view_cat = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/viewCat.tpl");
////////////////////////// BUILD SUB CATEGORIES////////
if(isset($_GET['catId'])) {
$_GET['catId'] = treatGet($_GET['catId']);
// build query
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY cat_name ASC";
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY pos";
// get category array in foreign innit
$resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".$lang_folder."'");
// query database
$subCategories = "";
$subCategories = $db->select($query);
}

if(isset($_GET['catId']) && $_GET['catId']>0 && $subCategories == TRUE) {
// loop results
for ($i=0; $i<count($subCategories); $i++){
if(is_array($resultsForeign)){
for ($k=0; $k<count($resultsForeign); $k++){
if($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']){
$subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];
}
}
}
}
}
?>

you need to check the closing braces at the end, I think I added the right amount

you also want to make sure nothing else from the end of that file was missed in all the pasting

semolinapilchard

3:52 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



i have spaced it all and closed up all brackets and now it says error on line 27

could it be a different file altogether that has error than one showing?

jatar_k

4:11 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



can you paste the exact error

semolinapilchard

4:22 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



Parse error: syntax error, unexpected T_IF in /home/xvuqvuh/public_html/store/includes/content/viewCat.inc.php on line 27

and the following code is from the above as i have it in smart ftp

<?php/*+--------------------------------------------------------------------------
¦ CubeCart v3.0.15¦
========================================
¦ by Alistair Brookbanks
¦CubeCart is a Trade Mark of Devellion Limited
¦ Copyright Devellion Limited 2005 - 2006. All rights reserved.
¦ Devellion Limited,
¦ 22 Thomas Heskin Court,
¦ Station Road,
¦ Bishops Stortford,
¦ HERTFORDSHIRE.
¦ CM23 3EE
¦ UNITED KINGDOM
¦ [devellion.com...]
¦UK Private Limited Company No. 5323904
¦ ========================================
¦ Web: [cubecart.com...]
¦ Date: Thursday, 4th January 2007
¦ Email: sales (at) cubecart (dot) com
¦License Type: CubeCart is NOT Open Source Software and Limitations Apply
¦ Licence Info: [cubecart.com...]
+--------------------------------------------------------------------------
¦viewCat.inc.php
¦ ========================================
¦Display the Current Category
+--------------------------------------------------------------------------
*/if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) ¦¦ eregi(".inc.php",$_SERVER['PHP_SELF'])) {
echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
exit;
}
if(isset($_GET['page'])){
$page = treatGet($_GET['page']);
} else {
$page = 0;}
$view_cat = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/viewCat.tpl");
////////////////////////// BUILD SUB CATEGORIES
////////
if(isset($_GET['catId'])) {
$_GET['catId'] = treatGet($_GET['catId']);
// build query
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY cat_name ASC";
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY pos";
// get category array in foreign innit
$resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".$lang_folder."'");
// query database
$subCategories = "";
$subCategories = $db->select($query);
}
if(isset($_GET['catId']) && $_GET['catId']>0 && $subCategories == TRUE) {
// loop results
for ($i=0; $i<count($subCategories); $i++){
if(is_array($resultsForeign)){
}
for ($k=0; $k<count($resultsForeign); $k++){
}
if($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']){
}$subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];

}if(empty($subCategories[$i]['cat_image'])){
$view_cat->assign("IMG_CATEGORY",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/catnophoto.gif");
} else {
$view_cat->assign("IMG_CATEGORY",$GLOBALS['rootRel']."images/uploads/".$subCategories[$i]['cat_image']);
}
$view_cat->assign("TXT_LINK_CATID",$subCategories[$i]['cat_id']);
$view_cat->assign("TXT_CATEGORY", validHTML($subCategories[$i]['cat_name']));
$view_cat->assign("NO_PRODUCTS",
$subCategories[$i]['noProducts']);
$view_cat->parse("view_cat.sub_cats.sub_cats_loop");
} // end loop results$view_cat->parse("view_cat.sub_cats");} // end $subCategories == TRUE


there is more but thought error would be in top bit

jatar_k

4:25 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



there are some more problems, I added some more linebreaks

I'm skipping all the top junk

<?php
if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) ¦¦ eregi(".inc.php",$_SERVER['PHP_SELF'])) {
echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
exit;
}
if(isset($_GET['page'])){
$page = treatGet($_GET['page']);
} else {
$page = 0;}
$view_cat = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/viewCat.tpl");
////////////////////////// BUILD SUB CATEGORIES
////////
if(isset($_GET['catId'])) {
$_GET['catId'] = treatGet($_GET['catId']);
// build query
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY cat_name ASC";
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY pos";
// get category array in foreign innit
$resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".$lang_folder."'");
// query database
$subCategories = "";
$subCategories = $db->select($query);
}
if(isset($_GET['catId']) && $_GET['catId']>0 && $subCategories == TRUE) {
// loop results
for ($i=0; $i<count($subCategories); $i++){
if(is_array($resultsForeign)){
}
for ($k=0; $k<count($resultsForeign); $k++){
}
if($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']){
}$subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];

}if(empty($subCategories[$i]['cat_image'])){
$view_cat->assign("IMG_CATEGORY",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/catnophoto.gif");
} else {
$view_cat->assign("IMG_CATEGORY",$GLOBALS['rootRel']."images/uploads/".$subCategories[$i]['cat_image']);
}
$view_cat->assign("TXT_LINK_CATID",$subCategories[$i]['cat_id']);
$view_cat->assign("TXT_CATEGORY", validHTML($subCategories[$i]['cat_name']));
$view_cat->assign("NO_PRODUCTS",
$subCategories[$i]['noProducts']);
$view_cat->parse("view_cat.sub_cats.sub_cats_loop");
} // end loop results
$view_cat->parse("view_cat.sub_cats");
} // end
$subCategories == TRUE
?>

semolinapilchard

6:47 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



thank you jatar - have copied and pasted that in and now its coming up with these errors:

Warning: Unterminated comment starting line 1 in /home/xvuqvuh/public_html/store/includes/content/viewCat.inc.php on line 1

Parse error: syntax error, unexpected $end in /home/xvuqvuh/public_html/store/includes/content/viewCat.inc.php on line 1

semolinapilchard

6:58 pm on Oct 31, 2007 (gmt 0)

10+ Year Member



thanks everyone for trying to help me out - i have just uploaded my back up file and it works fine and the categories have stayed as i arranged them so for now i will leave it as it is!

jatar_k

7:12 pm on Oct 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



guaranteed if you got it all formatted correctly that is all the problem is

glad you had a backup ;)