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