Wolphie Posted February 29, 2008 Share Posted February 29, 2008 I get this error: Parse error: syntax error, unexpected T_OBJECT_OPERATOR in E:\WebServer\htdocs\tutorials\addnew.php on line 18 This is the snippet: <?php if(!$cat_id == 0) { $sql = $auth->query(sprintf("INSERT INTO `tutorials` ( `user_id`, `title`, `author`, `content`, `cat_id` ) VALUES ( '%s', '%s', '%s', '%s', '%s' )", $userid, $title, $author, $content, $cat_id)); if($sql) { $sql = auth->query("SELECT `id` FROM `tutorials` ORDER BY `id` DESC LIMIT 1")); if($obj = $auth->fetch_object($sql)) { echo '<meta http-equiv="refresh" content="0;url=tutorials.php?id=' . $obj->id . ' />'; } } } else { echo 'Please select a category.<br />'; } ?> And this is line 18: if($obj = $auth->fetch_object($sql)) { This is my fetch object function: <?php function fetch_object($query_id = "") { if($query_id == NULL) { $return = mysql_fetch_object($this->query_result); } else { $return = mysql_fetch_object($query_id); } if(!$return) { $this->error(); } else { return $return; } } ?> I'm not too familiar with OOP however, this is more of a learning curb. Link to comment https://forums.phpfreaks.com/topic/93776-mysql-class/ Share on other sites More sharing options...
Barand Posted March 1, 2008 Share Posted March 1, 2008 Should it be if($obj = $sql->fetch_object($sql)) { EDIT: Ignore that. Link to comment https://forums.phpfreaks.com/topic/93776-mysql-class/#findComment-480557 Share on other sites More sharing options...
Wolphie Posted March 1, 2008 Author Share Posted March 1, 2008 Anybody? Link to comment https://forums.phpfreaks.com/topic/93776-mysql-class/#findComment-480985 Share on other sites More sharing options...
toplay Posted March 1, 2008 Share Posted March 1, 2008 Sometimes the error isn't on the line designated but earlier in the code...always look a line or more above too. Change this: $sql = auth->query("SELECT `id` FROM `tutorials` ORDER BY `id` DESC LIMIT 1")); To this - you have an extra right parenthesis at the end: $sql = auth->query("SELECT `id` FROM `tutorials` ORDER BY `id` DESC LIMIT 1"); Link to comment https://forums.phpfreaks.com/topic/93776-mysql-class/#findComment-480992 Share on other sites More sharing options...
Wolphie Posted March 1, 2008 Author Share Posted March 1, 2008 ah i see, thanks! Link to comment https://forums.phpfreaks.com/topic/93776-mysql-class/#findComment-481098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.