PHP中的MySQL语法错误

The error message: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'portfolio' at line 1"

Here is the offending code:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$host="****"; // Host name 
$username="****"; // Mysql username 
$password="****"; // Mysql password 
$db_name="a9307665_br"; // Database name 
$tbl_name="portfolio"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die(mysql_error()); 
mysql_select_db("$db_name")or die(mysql_error());

$query_getPosts = "SELECT post_id, title, updated FROM $tbl_name ORDER BY updated DESC";
$getPosts = mysql_query($tbl_name) or die(mysql_error());
$row_getPosts = mysql_fetch_assoc($getPosts);
$totalRows_getPosts = mysql_num_rows($getPosts);
?>

And I presume seeing as the error is MySQL based this is the line of code which is causing the error:

$query_getPosts = "SELECT post_id, title, updated FROM $tbl_name ORDER BY updated DESC";

Can someone point me in the right direction please?

UPDATE: The result of: echo $query_getPosts;

SELECT post_id, title, updated FROM `portfolio` ORDER BY updated DESC

You can try wrap your table name with backticks -

$query_getPosts = "SELECT post_id, title, updated FROM `$tbl_name` ORDER BY updated DESC";

Also you are specifying the table name as the query string :)

mysql_query($tbl_name)

Try

mysql_query($query_getPosts)

this line is wrong :

$getPosts = mysql_query($tbl_name) or die(mysql_error());

correct to this :

$getPosts = mysql_query($query_getPosts) or die(mysql_error());