0

Hello everyone!

I am having a problem. I receive an error below.

Parse error: syntax error, unexpected ')', expecting '(' in /home/fundis/public_html/ww.incs/basics.php on line 27

Here is my 'basics.php'.

<?php
session_start();

function __autoload($name) {
require $name . '.php';
}
function dbInit(){
if(isset($GLOBALS['db']))return $GLOBALS['db'];
global $DBVARS;
$db=new PDO('mysql:host='.$DBVARS['hostname']
.';dbname='.$DBVARS['db_name'],
$DBVARS['username'],
$DBVARS['password']
);
$db->query('SET NAMES utf8');
$db->num_queries=0;
$GLOBALS['db']=$db;
return $db;
}
function dbQuery($query){
$db=dbInit();
$q=$db->query($query);
$db->num_queries++;
return $q;
function dbRow($query) {
$q = dbQuery($query);
return $q->fetch (PDO::FETCH_ASSOC);
}
}

define('SCRIPTBASE', $_SERVER['DOCUMENT_ROOT'] . '/');
require SCRIPTBASE . '.private/config.php';
if(!defined('CONFIG_FILE'))
define('CONFIG_FILE',SCRIPTBASE.'.private/config.php');
set_include_path(SCRIPTBASE.'ww.php_classes'
.PATH_SEPARATOR.get_include_path());

I would be grateful if you could help me solving that problem.

Thank you.

Tibor

4
Contributors
11
Replies
12
Views
5 Years
Discussion Span
Last Post by broj1
Featured Replies
  • 2

    The closing curly bracket } on line 28 should actually be just after line 24 (at the end of the function dbQuery). These things are quite easy to spot if you use indentation and editor with syntax highlighting. [CODE]<?php session_start(); function __autoload($name) { require $name . '.php'; } function dbInit(){ … Read More

2

The closing curly bracket } on line 28 should actually be just after line 24 (at the end of the function dbQuery). These things are quite easy to spot if you use indentation and editor with syntax highlighting.

<?php
session_start();

function __autoload($name) {
    require $name . '.php';
}
function dbInit(){
    if(isset($GLOBALS['db']))return $GLOBALS['db'];
        global $DBVARS;
    $db=new PDO('mysql:host='.$DBVARS['hostname']
            .';dbname='.$DBVARS['db_name'],
        $DBVARS['username'],
        $DBVARS['password']
    );
    $db->query('SET NAMES utf8');
    $db->num_queries=0;
    $GLOBALS['db']=$db;
    return $db;
}
function dbQuery($query){
    $db=dbInit();
    $q=$db->query($query);
    $db->num_queries++;
    return $q;
}
function dbRow($query) {
    $q = dbQuery($query);
    return $q->fetch (PDO::FETCH_ASSOC);
}

define('SCRIPTBASE', $_SERVER['DOCUMENT_ROOT'] . '/');
require SCRIPTBASE . '.private/config.php';
if(!defined('CONFIG_FILE'))
    define('CONFIG_FILE',SCRIPTBASE.'.private/config.php');
set_include_path(SCRIPTBASE.'ww.php_classes'
    .PATH_SEPARATOR.get_include_path());  
?>
0

Thank you, but it still says the same as i copied your php syntax, but now it found the problem in the 28th line.

Any other ideas?!

Thanks.

0

There is some problem with the --> return $q->fetch (PDO::FETCH_ASSOC); line i think.

0
return $q->fetch(PDO::FETCH_ASSOC);

try without the space between fetch and '(' - but I don't think that's the issue though.

0

And what if the problem comes from my PHP or Mysql setup?

Because I am really dummie with setup.

0

If you really can't find a solution, might just be worth using trial and error; try inserting an extra bracket here and there.

Or cut all of your code into a separate document, and piece by piece add it back, testing each part?

I know it's a bit of a long shot.

0

Maybe you should check the included .private/config.php file. Maybe there is bracket missing in it? Maybe you could post it (remove passwords first if any).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.