tomfmason Posted October 26, 2006 Share Posted October 26, 2006 I have a class file that I just added another class to. It is a simple grouping of a few functions. I thought I could right this class in 15 minutes without a problem. Well I was half right..lolThis is the error that I got.Parse error: syntax error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/www/mahedidu/includes/classes.inc.php on line 152Line 152 is the last line of the file.. I thought oh great now I am going to have to inspect the file line by line. Well I did that and I don't see where the issue is. I will post the class in question.[code]<?phpclass messages { function messageCount($username) { $status = 'new'; $sql = mysql_query("SELECT * FROM `messages` WHERE `m_to` = '$username' AND `status` = '$status'"); $count = mysql_num_rows($sql); if ($count == 1) { $amount = 'You have 1 new message.'; } else { $amount = 'You have ' . $count . ' new messages.'; } return $amount; } function inBox($username) { $messages = array(); $sql = "SELECT `m_id`, `m_from`, DATE_FORMAT(m_date, '%M %D %Y') AS `formated_date`, TIME_FORMAT(m_time, '%r') AS `formated_date`, `subject` FROM `messages` WHERE `to` = '$username'"; $res = mysql_query($sql); if (mysql_num_rows($res) < 1) { $mess = 'You have no messages'; return $mess; }else{ while ($rw = mysql_fetch_assoc($res)) { $messages[] = '<tr><td bgcolor="#DEDED3" width="20%"><b>' . $rw['m_from'] . '</b></td> <td bgcolor="#DEDED3" width="20%"><b>' . $rw['m_subject'] . '</b></td> <td bgcolor="#DEDED3" width="15%"><b>' . $rw['formated_date'] . '</b></td> <td bgcolor="#DEDED3" width="15%"><b>' . $rw['formated_time'] . '</b></td> <td bgcolor="#DEDED3" width="10%"><a href="index.php?page=read&id=' . $rw['m_id'] .'"><b>Read</b></a></td> <td bgcolor="#DEDED3" width="10%"> </td> <td bgcolor="#DEDED3" width="10%"><a href="index.php?page=delete&id=' . $rw['m_id'] .'"><b>Delete</b></a></td></tr>'; } return $messages; } function sendMessage($from, $to, $subject, $message) { $status = 'new'; $sql = "INSERT INTO `messages` (`m_from`, `m_to`, `m_date`, `m_time`, `m_subject`, `m_message`, `m_status`) VALUES ('$from', '$to', now(), now(), '$subject', '$message', '$status'"; $res = mysql_query($sql); } function getMessage($id) { $message = array(); $sql = "SELECT `m_id`, `m_from`, DATE_FORMAT(m_date, '%M %D %Y') AS `formated_date`, TIME_FORMAT(m_time, '%r') AS `formated_date`, `subject` FROM `messages` WHERE `m_id` = '$id'"; $res = mysql_query($sql); while ($rw = mysql_fetch_assoc($res)) { $message['id'] = $rw['m_id']; $message['from'] = $rw['m_from']; $message['date'] = $rw['formated_date']; $message['time'] = $rw['formated_time']; $message['subject'] = $rw['m_subject']; $message['message'] = $rw['m_message']; } return $message; } function deleteMessage($id) { $sql = mysql_query("DELETE FROM `messages` WHERE `m_id` = '$id'"); if (!$sql) { $message = 'There was an error in deleteing your message. Please contact the webmaster'; } else { $message = 'Your message has been deleted'; } return $message; } }?>[/code]Can anyone see where I am going wrong..??Thanks,Tom Quote Link to comment Share on other sites More sharing options...
Orio Posted October 26, 2006 Share Posted October 26, 2006 Over here:[code]<?php function inBox($username) { $messages = array(); $sql = "SELECT `m_id`, `m_from`, DATE_FORMAT(m_date, '%M %D %Y') AS `formated_date`, TIME_FORMAT(m_time, '%r') AS `formated_date`, `subject` FROM `messages` WHERE `to` = '$username'"; $res = mysql_query($sql); if (mysql_num_rows($res) < 1) { $mess = 'You have no messages'; return $mess; }else{ while ($rw = mysql_fetch_assoc($res)) { $messages[] = '<tr><td bgcolor="#DEDED3" width="20%"><b>' . $rw['m_from'] . '</b></td> <td bgcolor="#DEDED3" width="20%"><b>' . $rw['m_subject'] . '</b></td> <td bgcolor="#DEDED3" width="15%"><b>' . $rw['formated_date'] . '</b></td> <td bgcolor="#DEDED3" width="15%"><b>' . $rw['formated_time'] . '</b></td> <td bgcolor="#DEDED3" width="10%"><a href="index.php?page=read&id=' . $rw['m_id'] .'"><b>Read</b></a></td> <td bgcolor="#DEDED3" width="10%"> </td> <td bgcolor="#DEDED3" width="10%"><a href="index.php?page=delete&id=' . $rw['m_id'] .'"><b>Delete</b></a></td></tr>'; } return $messages; }?>[/code]You for got to close the else, you only closed the loop and the function, so the compiler thinks everything is inside the inbox function, and then it get's an error at the end because of a missing "}".Orio. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted October 26, 2006 Author Share Posted October 26, 2006 LOL.. thanks.. I have been making alot of those small mistakes here lately..Thanks again,Tom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.