Jump to content

[SOLVED] What the heck is wrong with the code?


jrws

Recommended Posts

I simply get this error:

 

Parse error: syntax error, unexpected '}' in D:\xampp\xampp\htdocs\Website\v1\lib\classes\mysql.php on line 7

But I cannot see what it is talking about, I am new to OOP so it may be something simple:

//Testing the classes to make sure the work.
require_once('../inc/config.php');
error_reporting(E_ALL);
$mysql = new mysql();
$query= "CREATE TABLE `test_mysql` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`lastname` varchar(65) NOT NULL default '',
`email` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=0 ;";
$mysql ->query($query);

The code I run to get the error, and heres the mysql class:

    function FetchArray($sql)
    {
        $sql = $this->query($sql);
        $sql = mysql_fetch_array($sql) or die(mysql_error());
        return $sql;
    }
    function FetchRow($sql)
    {
        $rows = mysql_fetch_row($sql)or die(mysql_error());
        return $rows;
    }
    
    function Num_Rows($sql)
    {
        $sql = $this->query($sql);
        $sql = mysql_num_rows($sql) or die(mysql_error());
        return $sql;

    }
    function __destruct(){
	$this->close();
}
}

And just for good measure here is the config file.

 

<?php
//Database info
//Change these as needed
	define(DBHOST,'localhost');
define(DBUSER,'root');
define(DBPASS,'');
define(DATABASE,'site');
$PHPLIB_DIR = $_SERVER['DOCUMENT_ROOT'] . '../lib/classes';
$TEMPLATE_DIR =$_SERVER['DOCUMENT_ROOT'] . '../lib/templates';
//Site information, most if not all these things can be edited via the admin control panel
$Admin_Email ='admin@sandstorm.net';//The administrator email
$Cookie_Time= 86400;//How long the cookie lasts
//Custom error message, there is no need to use it if you don't want to.
$Custom_Error = '<br>An error has occured, please contact the site administrator at '. $Admin_Email .'and include and details such as what page and what appeared to be the error occording to the site.';
$Send_Email=0;//0=False, 1 = true, send a confirmation email.
//CHANGE ONLY THE Location of the classes
function __autoload($class)
{
    $classpath = '../classes/' . $class . '.php';
    if (file_exists($classpath)) {
        require_once $classpath;
    }
    $classpath = 'libs/' . $class . '.php';
    if (file_exists($classpath)) {
        require_once $classpath;
  }
  }

The config file

Link to comment
Share on other sites

It is, that is the whole code, and I will check for the at the end. Thanks for your reply.
Absolutely no class definition at all, not even opening and closing php tags, literally just a block of php code for a set of functions.

How is this being included in your main script? Using eval()?

Link to comment
Share on other sites

Like I said, I am new to PHP, and I was advised by an Author of a book to just use the opening tags if it is only going to be php. I have also solved the problem. Turned out I keep doing the same thing. I keep forgetting a simple ; or $. Anyway thanks.

 

Edit: I see your comment now. Seems the forums didn't post the whole code, no matter the problem is solved so thanks again.

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.