Codoforum related discussions
mySQL Fatal Error

On certain posts, I get this long error after submission but the post is submitted either way.

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-20' at line 1' in /home/admin/web/website.com/public_html/forum/sys/CODOF/Forum/Post.php:53 Stack trace: #0 /home/admin/web/website.com/public_html/forum/sys/CODOF/Forum/Post.php(53): PDO->query('SELECT u.id, r....') #1 /home/admin/web/website.com/public_html/forum/sys/Controller/Ajax/forum/topic.php(84): CODOF\Forum\Post->get_posts(22, -1) #2 /home/admin/web/website.com/public_html/forum/sys/Controller/forum.php(373): Controller\Ajax\forum\topic->get_posts(22, -1, Array) #3 /home/admin/web/website.com/public_html/forum/routes.php(904): Controller\forum->topic(22, 'Before 19 Octob...') #4 [internal function]: {closure}('22', 'Created cPanel ...', 'Before 19 Octob...') #5 /home/admin/web/website.com/public_html/forum/sys/Ext/limonade/limonade.php(42 in /home/admin/web/website.com/public_html/forum/sys/CODOF/Forum/Post.php on line 53
On certain posts, I get this long error after submission but the post is submitted either way. ```` Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-20' at line 1' in /home/admin/web/website.com/public_html/forum/sys/CODOF/Forum/Post.php:53 Stack trace: #0 /home/admin/web/website.com/public_html/forum/sys/CODOF/Forum/Post.php(53): PDO->query('SELECT u.id, r....') #1 /home/admin/web/website.com/public_html/forum/sys/Controller/Ajax/forum/topic.php(84): CODOF\Forum\Post->get_posts(22, -1) #2 /home/admin/web/website.com/public_html/forum/sys/Controller/forum.php(373): Controller\Ajax\forum\topic->get_posts(22, -1, Array) #3 /home/admin/web/website.com/public_html/forum/routes.php(904): Controller\forum->topic(22, 'Before 19 Octob...') #4 [internal function]: {closure}('22', 'Created cPanel ...', 'Before 19 Octob...') #5 /home/admin/web/website.com/public_html/forum/sys/Ext/limonade/limonade.php(42 in /home/admin/web/website.com/public_html/forum/sys/CODOF/Forum/Post.php on line 53 ````

This was an old problem which was fixed. Which version of codoforum are you using ?

This was an old problem which was fixed. Which version of codoforum are you using ?

I'm using codoforum.v.3.5.1. Upgraded to it from the backend.

I'm using codoforum.v.3.5.1. Upgraded to it from the backend.

hi guys

Getting the same error and I've just upgraded.

Error comes from trying to edit a post - then as soon as I click 'Save' I get the error

thanks

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-20' at line 1' in /var/www/vhosts/ophm.org/httpdocs/forum/sys/CODOF/Forum/Post.php:53 Stack trace: #0 /var/www/vhosts/ophm.org/httpdocs/forum/sys/CODOF/Forum/Post.php(53): PDO->query('SELECT u.id, r....'smile #1 /var/www/vhosts/ophm.org/httpdocs/forum/sys/Controller/Ajax/forum/topic.php(84): CODOF\Forum\Post->get_posts(3, -1) #2 /var/www/vhosts/ophm.org/httpdocs/forum/sys/Controller/forum.php(373): Controller\Ajax\forum\topic->get_posts(3, -1, Array) #3 /var/www/vhosts/ophm.org/httpdocs/forum/routes.php(879): Controller\forum->topic(3, 'Nov 2016'smile #4 [internal function]: {closure}('3', 'The Osteopath m...', 'Nov 2016'smile #5 /var/www/vhosts/ophm.org/httpdocs/forum/sys/Ext/limonade/limonade.php(429): call_user_func_array(Object(Closure), Array) #6 /var/www/vhosts/ophm.org/httpdoc in /var/www/vhosts/ophm.org/httpdocs/forum/sys/CODOF/Forum/Post.php on line 53

hi guys Getting the same error and I've just upgraded. Error comes from trying to edit a post - then as soon as I click 'Save' I get the error thanks Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-20' at line 1' in /var/www/vhosts/ophm.org/httpdocs/forum/sys/CODOF/Forum/Post.php:53 Stack trace: #0 /var/www/vhosts/ophm.org/httpdocs/forum/sys/CODOF/Forum/Post.php(53): PDO->query('SELECT u.id, r....') #1 /var/www/vhosts/ophm.org/httpdocs/forum/sys/Controller/Ajax/forum/topic.php(84): CODOF\Forum\Post->get_posts(3, -1) #2 /var/www/vhosts/ophm.org/httpdocs/forum/sys/Controller/forum.php(373): Controller\Ajax\forum\topic->get_posts(3, -1, Array) #3 /var/www/vhosts/ophm.org/httpdocs/forum/routes.php(879): Controller\forum->topic(3, 'Nov 2016') #4 [internal function]: {closure}('3', 'The Osteopath m...', 'Nov 2016') #5 /var/www/vhosts/ophm.org/httpdocs/forum/sys/Ext/limonade/limonade.php(429): call_user_func_array(Object(Closure), Array) #6 /var/www/vhosts/ophm.org/httpdoc in /var/www/vhosts/ophm.org/httpdocs/forum/sys/CODOF/Forum/Post.php on line 53
edited Nov 15 '16 at 12:23 pm

I can't contact him - tried clicking on the link and I get a fatal error !

I suppose I could dump the database, install the new version then just upload the dumped file ?

I can't contact him - tried clicking on the link and I get a fatal error ! I suppose I could dump the database, install the new version then just upload the dumped file ?

hi

That path doesn't exist...

In sys all I have is:

583c548f005b3.png

hi That path doesn't exist... In sys all I have is: ![583c548f005b3.png](serve/attachment&path=583c548f005b3.png)

thank you - attached

<?php

/*
 * @CODOLICENSE
 *  
 * 
 * issue system
 * 
 *    users can view own content
 *    users cannot view others content
 * 
 *    moderators/admin -> full priveleges
 * 
 * 
 * premium member system
 * 
 *   role A can access forum B
 * 
 * 
 * 
 * 
 */

namespace CODOF\Forum;

class Topic extends Forum {

    //put your code here

    protected $db;
    public $ajax = false;
    public $new_topic_ids = array();
    public $new_replies = array();
    public $tags = array();

    public function __construct($db) {

        $this->db = $db;
    }

    //TODO: make this a little more reusable
    public function get_topics($cat_id, $page = 1) {

        //$t = microtime(true);
        $cat_id = (int) $cat_id;
        $topics = array();
        $num_posts = \CODOF\Util::get_opt("num_posts_cat_topics");
        $from = ($page - 1) * $num_posts;
        //username , title, topic created, no of replies,
        $qry = 'SELECT p.post_id,p.omessage AS message, p.post_created, r.rid, u.id, u.name AS name, u.avatar, '
                . 't.topic_id, t.uid, t.no_posts, t.no_views, t.title, t.topic_created,last_post_id, '
                . 't.last_post_name AS lname, t.last_post_uid AS luid, t.last_post_time AS lpost_time,'
                . 't.topic_status '
                . 'FROM ' . PREFIX . 'codo_topics AS t '
                . 'LEFT JOIN ' . PREFIX . 'codo_posts AS p ON (t.post_id=p.post_id AND p.post_status=1) '
                . 'LEFT JOIN ' . PREFIX . 'codo_users AS u ON u.id=p.uid '
                . 'LEFT JOIN ' . PREFIX . 'codo_user_roles AS r ON u.id=r.uid AND r.is_primary=1 '
                . 'WHERE t.cat_id=' . $cat_id
                . ' AND ('
                . ' t.topic_status=' . Forum::APPROVED . ' OR'
                . ' t.topic_status=' . Forum::APPROVED_CLOSED . ' OR'
                . ' t.topic_status=' . Forum::STICKY . ' OR'
                . ' t.topic_status=' . Forum::STICKY_CLOSED . ' OR'
                . ' t.topic_status=' . Forum::STICKY_ONLY_CATEGORY . ' OR'
                . ' t.topic_status=' . Forum::STICKY_ONLY_CATEGORY_CLOSED . '  ) AND '
                . $this->getViewTopicPermissionConditions()
                . 'ORDER BY t.topic_status DESC, t.last_post_time DESC LIMIT ' . $num_posts . ' OFFSET ' . $from;

        $stmt = $this->db->query($qry);
        if ($stmt) {

            return $stmt->fetchAll();
        }

        return $topics;
    }

    public function getTaggedTopics($tag, $from = 0) {

        $_topics = array();
        //$t = microtime(true);
        $num_posts = \CODOF\Util::get_opt("num_posts_all_topics");
        //username , title, topic created, no of replies,
        $qry = 'SELECT p.post_id, p.omessage AS message, p.post_created, r.rid, u.id, u.name as name, u.avatar, c.cat_img, c.cat_alias,'
                . 't.topic_id, t.uid, t.title, t.no_posts, t.no_views, t.last_post_time, t.last_post_uid, '
                . 't.last_post_name AS last_post_name, t.topic_created, t.cat_id, last_post_id,t.topic_status '
                . 'FROM codo_topics AS t INNER JOIN codo_tags as g ON g.topic_id=t.topic_id '
                . 'LEFT JOIN codo_posts AS p ON (t.post_id=p.post_id AND p.post_status=1)'
                . 'LEFT JOIN codo_users AS u ON u.id=p.uid '
                . 'LEFT JOIN codo_categories AS c ON c.cat_id=t.cat_id '
                . 'LEFT JOIN ' . PREFIX . 'codo_user_roles AS r ON u.id=r.uid AND r.is_primary=1 '                
                . ' WHERE ('
                . ' t.topic_status=' . Forum::APPROVED . ' OR'
                . ' t.topic_status=' . Forum::APPROVED_CLOSED . ' OR'
                . ' t.topic_status=' . Forum::STICKY . ' OR'
                . ' t.topic_status=' . Forum::STICKY_CLOSED . ' OR'
                . ' t.topic_status=' . Forum::STICKY_ONLY_CATEGORY . ' OR'
                . ' t.topic_status=' . Forum::STICKY_ONLY_CATEGORY_CLOSED . '  ) AND '
                . $this->getViewTopicPermissionConditions()
                . ' AND g.tag_name=' . $this->db->quote($tag)
                . ' ORDER BY t.last_post_time DESC LIMIT  ' . $num_posts . ' OFFSET ' . $from;

        $ans = $this->db->query($qry);
        //echo $qry;
        if ($ans) {

            $topics = $ans->fetchAll();
            $_topics = $this->gen_topic_arr_all_topics($topics);
        }
        //echo " <br/>get_all_topics() ";
        //echo microtime(true) - $t;

        return $_topics;
    }
thank you - attached ``` &lt;?php /* * @CODOLICENSE * * * issue system * * users can view own content * users cannot view others content * * moderators/admin -&gt; full priveleges * * * premium member system * * role A can access forum B * * * * */ namespace CODOF\Forum; class Topic extends Forum { //put your code here protected $db; public $ajax = false; public $new_topic_ids = array(); public $new_replies = array(); public $tags = array(); public function __construct($db) { $this-&gt;db = $db; } //TODO: make this a little more reusable public function get_topics($cat_id, $page = 1) { //$t = microtime(true); $cat_id = (int) $cat_id; $topics = array(); $num_posts = \CODOF\Util::get_opt(&quot;num_posts_cat_topics&quot;); $from = ($page - 1) * $num_posts; //username , title, topic created, no of replies, $qry = &#039;SELECT p.post_id,p.omessage AS message, p.post_created, r.rid, u.id, u.name AS name, u.avatar, &#039; . &#039;t.topic_id, t.uid, t.no_posts, t.no_views, t.title, t.topic_created,last_post_id, &#039; . &#039;t.last_post_name AS lname, t.last_post_uid AS luid, t.last_post_time AS lpost_time,&#039; . &#039;t.topic_status &#039; . &#039;FROM &#039; . PREFIX . &#039;codo_topics AS t &#039; . &#039;LEFT JOIN &#039; . PREFIX . &#039;codo_posts AS p ON (t.post_id=p.post_id AND p.post_status=1) &#039; . &#039;LEFT JOIN &#039; . PREFIX . &#039;codo_users AS u ON u.id=p.uid &#039; . &#039;LEFT JOIN &#039; . PREFIX . &#039;codo_user_roles AS r ON u.id=r.uid AND r.is_primary=1 &#039; . &#039;WHERE t.cat_id=&#039; . $cat_id . &#039; AND (&#039; . &#039; t.topic_status=&#039; . Forum::APPROVED . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::APPROVED_CLOSED . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY_CLOSED . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY_ONLY_CATEGORY . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY_ONLY_CATEGORY_CLOSED . &#039; ) AND &#039; . $this-&gt;getViewTopicPermissionConditions() . &#039;ORDER BY t.topic_status DESC, t.last_post_time DESC LIMIT &#039; . $num_posts . &#039; OFFSET &#039; . $from; $stmt = $this-&gt;db-&gt;query($qry); if ($stmt) { return $stmt-&gt;fetchAll(); } return $topics; } public function getTaggedTopics($tag, $from = 0) { $_topics = array(); //$t = microtime(true); $num_posts = \CODOF\Util::get_opt(&quot;num_posts_all_topics&quot;); //username , title, topic created, no of replies, $qry = &#039;SELECT p.post_id, p.omessage AS message, p.post_created, r.rid, u.id, u.name as name, u.avatar, c.cat_img, c.cat_alias,&#039; . &#039;t.topic_id, t.uid, t.title, t.no_posts, t.no_views, t.last_post_time, t.last_post_uid, &#039; . &#039;t.last_post_name AS last_post_name, t.topic_created, t.cat_id, last_post_id,t.topic_status &#039; . &#039;FROM codo_topics AS t INNER JOIN codo_tags as g ON g.topic_id=t.topic_id &#039; . &#039;LEFT JOIN codo_posts AS p ON (t.post_id=p.post_id AND p.post_status=1)&#039; . &#039;LEFT JOIN codo_users AS u ON u.id=p.uid &#039; . &#039;LEFT JOIN codo_categories AS c ON c.cat_id=t.cat_id &#039; . &#039;LEFT JOIN &#039; . PREFIX . &#039;codo_user_roles AS r ON u.id=r.uid AND r.is_primary=1 &#039; . &#039; WHERE (&#039; . &#039; t.topic_status=&#039; . Forum::APPROVED . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::APPROVED_CLOSED . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY_CLOSED . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY_ONLY_CATEGORY . &#039; OR&#039; . &#039; t.topic_status=&#039; . Forum::STICKY_ONLY_CATEGORY_CLOSED . &#039; ) AND &#039; . $this-&gt;getViewTopicPermissionConditions() . &#039; AND g.tag_name=&#039; . $this-&gt;db-&gt;quote($tag) . &#039; ORDER BY t.last_post_time DESC LIMIT &#039; . $num_posts . &#039; OFFSET &#039; . $from; $ans = $this-&gt;db-&gt;query($qry); //echo $qry; if ($ans) { $topics = $ans-&gt;fetchAll(); $_topics = $this-&gt;gen_topic_arr_all_topics($topics); } //echo &quot; &lt;br/&gt;get_all_topics() &quot;; //echo microtime(true) - $t; return $_topics; } ```
edited Nov 28 '16 at 6:11 pm

Can you email me that file and sys/CODOF/Forum/Post.php ? (admin[@]codologic.com)

As its difficult to tell all the changes here.

Can you email me that file and sys/CODOF/Forum/Post.php ? (admin[@]codologic.com) As its difficult to tell all the changes here.
548
13
4
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft