Jump to content

PHP code problem - unexpected T VARIABLE


Broomy

Recommended Posts

Hi. I have this code that someone wrote for me, but it gives me an error if I try and use it as follows:

Parse error: syntax error, unexpected T_VARIABLE

The line with the error refers to $sql = "

I'm useless at PHP but i'm hoping that someone might be able to point out what the problem might be.

Thanks for any help.

[code]<?php

$currentNodeCreated = $node->created;
$taxonomyTerm = 2 //this should not be hardcoded, it should be pulled from the node details for the current node taxonomy

$sql = "
  SELECT node.title, node.nid
  FROM {node}, {term_node}
  WHERE node.nid = term_node.nid
  AND node.tid = $taxonomyTerm
  AND node.created < $currentNodeCreated
  AND node.status = 1
  ORDER BY node.created DESC
  LIMIT 1";
$result = db_query($sql);
if($row = db_fetch_result($result) {
  $output .= l($row->title, "node/".$row->nid);
}
?>[/code]
Link to comment
Share on other sites

Thanks for the help, I appreciate it. That problem is now fixed but i'm not met with this error:

Parse error: syntax error, unexpected '{' on the line that refers to this:

if($row = db_fetch_result($result) {

Any more help would be great,

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.