0

Is this function correct? it keeps returning: Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\Program Files (x86)\Apache Group\Apache2\htdocs\test\include\class.mysqltools.php on line 301

301 is the last line...any help is appreciated, thank you!

function DisplayA($query, $rowname1, $rowname2) {
    $result = mysql_query($query);
    $buffer = $buffer .="<table>";
    while($row = mysql_fetch_array($result)){
    $buffer = $buffer .="<tr><td>" . $row[$rowname1] . "</td><td>" . $row[$rowname2] . "</td></tr>";
    }
    $buffer = $buffer .="</table>";
    return $buffer;
}
  • 1
    http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – Geoffrey Burdett Nov 14 '13 at 17:23
  • I don't know if it's the issue, but `$buffer = $buffer .="";` isn't going to do what you want. You need either `$buffer = $buffer . "
    ";` or `$buffer .="
    ";` instead.
    – andrewsi Nov 14 '13 at 17:26

1 Answers1

1

Try:

function DisplayA($query, $rowname1, $rowname2) {
    $result = mysql_query($query);
    $buffer .= "<table>";
    while($row = mysql_fetch_array($result)){
        $buffer .= "<tr><td>" . $row[$rowname1] . "</td><td>" . $row[$rowname2] . "</td></tr>";
    }
    $buffer .= "</table>";
    return $buffer;
}

Not sure if your $buffer = $buffer .= may have been causing some unexpected results. Change all instances of this to just $buffer .=

Josh Harrison
  • 5,927
  • 1
  • 30
  • 44