j634 Posted December 10, 2007 Share Posted December 10, 2007 Hi, I am getting this error on my news page of my web site. 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 'call from hl_news' at line 1 I can't find the error in my code. This is the entire code of my news page. <? $q = 'select count(*) as call from hl_news '; if (!($sth = mysql_query ($q))) { print mysql_error ()); ; } $row = mysql_fetch_array ($sth); $count_all = $row['call']; $page = $frm['page']; $onpage = 20; $colpages = ceil ($count_all / $onpage); if ($page <= 1) { $page = 1; } if (($colpages < $page AND 1 < $colpages)) { $page = $colpages; } $from = ($page - 1) * $onpage; $q = '' . 'select *, date_format(date, \'%b-%e-%Y %r\') as d from hl_news where (expiration = 0 || (date + interval expiration day >= current_date)) order by date desc limit ' . $from . ', ' . $onpage; ($sth = mysql_query ($q) OR print mysql_error ()); $news = array (); while ($row = mysql_fetch_array ($sth)) { if ($row['full_text'] == '') { $row['full_text'] = $row['small_text']; } $row['full_text'] = preg_replace ('/ /', '<br>', $row['full_text']); array_push ($news, $row); } $smarty->assign ('news', $news); $pages = array (); for ($i = 1; $i <= $colpages; ++$i) { $apage = array (); $apage['page'] = $i; $apage['current'] = ($i == $page ? 1 : 0); array_push ($pages, $apage); } $smarty->assign ('pages', $pages); $smarty->assign ('colpages', $colpages); $smarty->assign ('current_page', $page); if (1 < $page) { $smarty->assign ('prev_page', $page - 1); } if ($page < $colpages) { $smarty->assign ('next_page', $page + 1); } $smarty->display ('news.tpl'); ?> You can see at: http://www.hyipcharts.com and click on the more news button. Also, could you let me know how the page loads for you. I have to refresh sometimes or get a blank page. Thanks again for the great help, j634 Quote Link to comment Share on other sites More sharing options...
revraz Posted December 10, 2007 Share Posted December 10, 2007 CALL is a mysql reserved word. Quote Link to comment Share on other sites More sharing options...
j634 Posted December 10, 2007 Author Share Posted December 10, 2007 CALL is a mysql reserved word. I guess that explains it. Can I just change call to count? Thanks, j634 Quote Link to comment Share on other sites More sharing options...
trq Posted December 10, 2007 Share Posted December 10, 2007 Just sourround it with `backticks`. Quote Link to comment Share on other sites More sharing options...
j634 Posted December 10, 2007 Author Share Posted December 10, 2007 Just sourround it with `backticks`. I tried that and still can't get it to work. If I backtick it all I get is a blank page. I tried it like this and worked backwards. $q = 'select count(*) as `call` from hl_news '; if (!($sth = mysql_query ($q))) { print mysql_error ()); ; } $row = mysql_fetch_array ($sth); $count_all = $row[`call`]; $page = $frm['page']; $onpage = 20; I backticked both, saved and tried the page. I get a blank screen. I unbackticked the first call and the page comes, but with the same error. Thanks 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.