473,382 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help with Parse Error in PHP

Hi All,

Wonder if anyone can shed any light on this error I am getting.

I have the following error when trying to access my site:
"Parse error: syntax error, unexpected '(', expecting T_STRING in /dev/lookatme/_config/config.php on line 145"

I've looked at the code again but I can't figure out what is wrong... Here is the code.

Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3.  
  4. $config = array();
  5.  
  6. if ((strpos($_SERVER['SERVER_NAME'],'localhost') !== 0) && (strpos($_SERVER['SERVER_NAME'],'192.168.52.132') !== 0)) {
  7.     // LIVE SETTINGS
  8.     $config['site_url'] = "http://www.mysite.co.uk/dev/lookatme/";
  9.  
  10.     $config['database'] = "mysite_co_uk";
  11.     mysql_connect("mysite.co.uk.mysql","mysite_co_uk","L3Tm3Inn") or die("Unable to conn. to database");
  12.     @mysql_select_db($config['database']) or die("Unable to select database");
  13.  
  14.     // INI SETS
  15.     ini_set('include_path', '_inc/');
  16.  
  17.     // PATH TO SITE ROOT
  18.     $config['site_path'] = "";
  19.  
  20. } else {
  21.     // LOCAL SETTINGS
  22.     $config['site_url'] = "http://localhost/";
  23.  
  24.     $config['database'] = "localdb";
  25.     mysql_connect("localhost","root","12345") or die("Unable to conn. to database");
  26.     @mysql_select_db($config['database']) or die("Unable to select database");
  27.  
  28.     // INI SETS
  29.     ini_set('include_path', '_inc/');
  30.  
  31.     // PATH TO SITE ROOT
  32.     $config['site_path'] = "";
  33.  
  34. }
  35.  
  36. // webpage defaults
  37. $webpage = array();
  38. $webpage['id'] = "";
  39. $webpage['sets'] = array();
  40. $webpage['default'] = 0;
  41. $webpage['system'] = 1;
  42. $webpage['versionid'] = "";
  43. $webpage['version_name'] = "";
  44. $webpage['meta_title'] = "";
  45. $webpage['meta_keywords'] = "";
  46. $webpage['meta_description'] = "";
  47. $route = array();
  48.  
  49. $admin = array();
  50. $admin['id'] = (isset($_SESSION['adminid'])) ? $_SESSION['adminid'] : "" ;
  51. $admin['tab'] = (isset($_SESSION['admintab'])) ? $_SESSION['admintab'] : "" ;
  52.  
  53. $user = array();
  54. $user['spamprotect'] = (isset($_SESSION['spamprotect'])) ? $_SESSION['spamprotect'] : "" ;
  55.  
  56. if (isset($_GET['tab'])) {
  57.     $admin['tab'] = $_GET['tab'];
  58.     $_SESSION['admintab'] = $admin['tab'];
  59.  
  60. }
  61.  
  62.  
  63. // INCLUDES
  64. include("common.php");
  65. include("forms.php");
  66. include("sql_functions.php");
  67. include("emails.php");
  68. include("phpmailer/class.phpmailer.php");
  69. include("generator.php");
  70. include("cms_functions.php");
  71.  
  72. // DEFAULTS
  73.  
  74. $default = array();
  75.  
  76. // GET CONFIG DETAILS
  77.  
  78. $sql = "
  79.     SELECT
  80.         *
  81.     FROM
  82.         core_config
  83.     WHERE
  84.         active = '1'
  85. ";
  86. $result = mysql_query($sql);
  87. $num = mysql_numrows($result);
  88.  
  89. if ($num > 0) {
  90.     $i = 0;
  91.     while ($i < $num) {
  92.         $key = mysql_result($result,$i,"field");
  93.         $value = mysql_result($result,$i,"value");
  94.         $config[$key] = $value;
  95.     $i++;
  96.     }
  97.  
  98. }
  99.  
  100. // GET ADMIN DETAILS
  101.  
  102. if ($admin['id'] != "") {
  103.     $sql = "
  104.         SELECT
  105.             *
  106.         FROM
  107.             admin_users
  108.         INNER JOIN
  109.             admin_types ON
  110.             admin_users.typeid = admin_types.id
  111.         WHERE
  112.             admin_users.id='".$admin['id']."'
  113.         ";
  114.     $result = mysql_query($sql);
  115.     $num = mysql_num_rows($result);
  116.  
  117.     if ($num == 0) {
  118.         exit();
  119.     } else {
  120.         $admin['firstname'] = mysql_result($result,0,"firstname");
  121.         $admin['surname'] = mysql_result($result,0,"surname");
  122.         $admin['typeid'] = mysql_result($result,0,"typeid");
  123.         $admin['type'] = mysql_result($result,0,"name");
  124.         $admin['email'] = mysql_result($result,0,"email");
  125.     }
  126. } else {
  127.     $admin['firstname'] = "";
  128.     $admin['surname'] = "";
  129.     $admin['typeid'] = "";
  130.     $admin['type'] = "";
  131.     $admin['email'] = "";
  132. }
  133.  
  134. // SPAM PROTECTION
  135. if ( ($user['spamprotect'] == "") || ( ( (isset($_GET['spamprotect'])) && ($_GET['spamprotect'] == "refresh") ) ) ) {
  136.     $user['spamprotect'] = password_return_random(4);
  137.     $_SESSION['spamprotect'] = $user['spamprotect'];
  138. }
  139.  
  140. // HARD CODED ADMIN REDIRECT
  141. function page_requires_admin_login() {
  142.     extract($GLOBALS);
  143.     if ($admin['id'] == "") {
  144.         $msg = "0|Please Log In|You must sign in to view the page you were looking for.";
  145.         goto('../index/index.php?msg='.urlencode($msg));
  146.     }
  147. }
  148.  
  149.  
  150. // ADMIN TYPE REDIRECT
  151. function page_requires_admin_types($requiredtypes) {
  152.  
  153.     if ($requiredtypes != "") {
  154.         extract($GLOBALS);
  155.         $typearray = explode(",", $requiredtypes);
  156.  
  157.         if (!in_array($admin['typeid'], $typearray)) {
  158.             if ($admin['id'] == "") {
  159.                 $msg = "0|Sign In Required|Sorry, you can not view that page.";
  160.                 goto('../index/index.php?msg='.urlencode($msg));
  161.             } else {
  162.                 $msg = "0|Access Restricted|Sorry, you do not have access to that page.";
  163.                 goto('../index/index.php?msg='.urlencode($msg));
  164.             }
  165.         }
  166.     }
  167. }
  168.  
  169.  
  170.  
  171. // HTTP SWITCH
  172. function page_requires_https($v) {
  173.  
  174.     extract($GLOBALS);
  175.  
  176.     if ($config['https_enabled'] == "True") {
  177.  
  178.         if (isset($_SERVER['QUERY_STRING'])) {
  179.             $qs = "?".$_SERVER['QUERY_STRING'];
  180.         } else {
  181.             $qs = "";
  182.         }
  183.  
  184.         switch ($v) {
  185.             case "1":
  186.                 // https on
  187.                 if($_SERVER['HTTPS'] !== "on") {
  188.                     // redirect here
  189.                 }
  190.             break;
  191.             case "0":
  192.                 // https off
  193.                 if($_SERVER['HTTPS'] == "on") {
  194.                     // redirect here
  195.                 }
  196.             break;
  197.             case "2":
  198.                 // do nothing
  199.             break;
  200.         }
  201.     }
  202. }
  203.  
  204.  
  205. ?>
  206.  
Anyone got any suggestions - I'm now stumped on this one!

Cheers,

Jay
Aug 11 '10 #1

✓ answered by JKing

You should change the name of your function because goto is already a function in php.

4 11822
JKing
1,206 Expert 1GB
You are not using the goto command properly.
PHP Manual - goto

have a look at the header() function.PHP Manual - Header
Aug 11 '10 #2
Hey,

I also have this being called from a "Common" list of functions:

Expand|Select|Wrap|Line Numbers
  1. function goto($location) {
  2.  
  3.     $tag = "\\";
  4.  
  5.     if (dirname($_SERVER['SCRIPT_NAME']) == $tag) {
  6.         $str = "/";
  7.     } else {
  8.         $str = dirname($_SERVER['SCRIPT_NAME']);
  9.     }
  10.  
  11.     if ($_SERVER['HTTPS'] !== "on") {
  12.         header('location: http://'.$_SERVER['HTTP_HOST'].$str.'/'.$location);
  13.         exit();
  14.     } else {
  15.         header('location: https://'.$_SERVER['HTTP_HOST'].$str.'/'.$location);
  16.         exit();
  17.     }
  18.  
  19. }
  20.  
Aug 11 '10 #3
JKing
1,206 Expert 1GB
You should change the name of your function because goto is already a function in php.
Aug 12 '10 #4
Thanks JKing, thats spot on, I completely forgot and it came online after 5.2, my new server runs on 5.3.3 so hence the error.

All up and running.

Appreciate your help :-)
Aug 13 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: entoone | last post by:
I'm getting the following error Parse error: parse error, expecting `','' or `';'' in /home/notarywe/public_html/php/update2.php on line 108 Here is line 108 <input type="text" name="ud_first"...
3
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title>...
6
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
2
by: Andrew Ayers | last post by:
All, I am having a problem with an INSERT onto a table I have created. First off, here is the table: --- CREATE TABLE reg ("customer number" SERIAL PRIMARY KEY, "company name" ...
2
by: Vittal | last post by:
Hello All, I am trying to compile my application on Red Hat Linux 8 against gcc 3.2.2. Very first file in application is failing to compile. I tried compiling my application on Linux 7.2...
8
by: Brett Romero | last post by:
I get this error when I try to run my ASP.NET app on our server: Server Error in '/' Application. -------------------------------------------------------------------------------- Parser Error...
21
by: BWIGLEY | last post by:
Basically I've just started making a game. So far it makes an array 25 by 20 and tries to make five rooms within it. In scr_make_room() there's parse errors: 20 C:\c\Rooms\Untitled1.c parse error...
1
by: Phaelle | last post by:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' What does that error mean? I canīt find the mistake!! In another script, I have got another kind of mistake : parse...
0
by: badkitty63 | last post by:
I am getting this error Help!!!!!! Parse error: syntax error, unexpected T_STRING in /home/desertr3/public_html/includes/languages/english/shipping.php on line 18 I am trying to add shipping...
2
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.