Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Syntax Error inside PHP
    primarykey
    data
    text
    <p>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"</p> <p>Here is the offending code:</p> <pre><code>&lt;?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION &lt; 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); ?&gt; </code></pre> <p>And I presume seeing as the error is MySQL based this is the line of code which is causing the error:</p> <pre><code>$query_getPosts = "SELECT post_id, title, updated FROM $tbl_name ORDER BY updated DESC"; </code></pre> <p>Can someone point me in the right direction please?</p> <p>UPDATE: The result of: <code>echo $query_getPosts;</code></p> <pre><code>SELECT post_id, title, updated FROM `portfolio` ORDER BY updated DESC </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload