Jump to content

MySQL Class


Wolphie

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.