jrws Posted December 20, 2008 Share Posted December 20, 2008 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 ='[email protected]';//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 https://forums.phpfreaks.com/topic/137791-solved-what-the-heck-is-wrong-with-the-code/ Share on other sites More sharing options...
Mark Baker Posted December 20, 2008 Share Posted December 20, 2008 If mysql.php is a class, then you're not giving us the whole code to look at, otherwise there's a spurious } at the very bottom of what you have posted for that file Link to comment https://forums.phpfreaks.com/topic/137791-solved-what-the-heck-is-wrong-with-the-code/#findComment-720209 Share on other sites More sharing options...
jrws Posted December 20, 2008 Author Share Posted December 20, 2008 It is, that is the whole code, and I will check for the at the end. Thanks for your reply. Link to comment https://forums.phpfreaks.com/topic/137791-solved-what-the-heck-is-wrong-with-the-code/#findComment-720211 Share on other sites More sharing options...
Mark Baker Posted December 20, 2008 Share Posted December 20, 2008 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 https://forums.phpfreaks.com/topic/137791-solved-what-the-heck-is-wrong-with-the-code/#findComment-720216 Share on other sites More sharing options...
jrws Posted December 20, 2008 Author Share Posted December 20, 2008 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 https://forums.phpfreaks.com/topic/137791-solved-what-the-heck-is-wrong-with-the-code/#findComment-720217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.