By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

ERROR: SELECT cat_id, cat_name FROM in Wordpress Bolg

deephill
P: 37
hi
I am getting SELECT cat_id, cat_name FROM Error in Wordpress Blog. Im getting below error in my online site. Wht can i do?

WordPress database error: [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 '' at line 1]
SELECT cat_id, cat_name FROM
Sample template i am viewing Blogrolls. But in online site i cant. The code is...

[PHP]<?php
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
foreach ($link_cats as $link_cat) {
?>
<div class="widget_style" id="links_with_style">
<div class="cats_head">
<h2 class="h3">cat_name; ?>
</div>
<ul>
<?php get_links($link_cat->cat_id, '', '', '
', FALSE, 'rand', TRUE,
TRUE, -1, TRUE); ?>
</ul>
</div>
<?php } ?> [/PHP]


Anybody help me?
May 2 '07 #1
Share this Question
Share on Google+
7 Replies


100+
P: 136
Hi,

[PHP]$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");[/PHP]

I think you r not getting the file name using $wpdb->linkcategories

try to print out the query using

[PHP]echo "SELECT cat_id, cat_name FROM $wpdb->linkcategories"[/PHP]

susen
May 2 '07 #2

deephill
P: 37
Thank you...

im newbie. can u tell clearly. i.e. whr did i put this???
:-(
May 2 '07 #3

100+
P: 136
put the 2nd line of just above the 1st line of code. Now see if u r getting the sql query printed properly or not.

susen
May 4 '07 #4

deephill
P: 37
hi.. i put like this. but its same error. wht should i do?

[PHP]<?php
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
echo "SELECT cat_id, cat_name FROM $wpdb->linkcategories";
foreach ($link_cats as $link_cat) {
?>
<div class="widget_style" id="links_with_style">
<div class="cats_head">
<h2 class="h3">cat_name; ?>
</div>
<ul>
<?php get_links($link_cat->cat_id, '', '', '
', FALSE, 'rand', TRUE,
TRUE, -1, TRUE); ?>
</ul>
</div>
<?php } ?> [/PHP]
May 7 '07 #5

deephill
P: 37
hi i put like this.
[PHP]<?php
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
echo "SELECT cat_id, cat_name FROM $wpdb->linkcategories";
foreach ($link_cats as $link_cat) {
?>
<div class="widget_style" id="links_with_style">
<div class="cats_head">
<h2 class="h3">cat_name; ?>
</div>
<ul>
<?php get_links($link_cat->cat_id, '', '', '
', FALSE, 'rand', TRUE,
TRUE, -1, TRUE); ?>
</ul>
</div>
<?php } ?> [/PHP]

now i am getting below message in the sidebar.php....



Expand|Select|Wrap|Line Numbers
  1. WordPress database error: [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 '' at line 1]
  2.             SELECT cat_id, cat_name FROM 
  3.  
  4.  
  5. SELECT cat_id, cat_name FROM
May 7 '07 #6

100+
P: 136
HI,

so what I told u earlier that u r not getting value of $wpdb->linkcategories.

So first search if u have a table named wp_linkcategories in ur database or not. Now if the table is there then search wp-config.php or wp-settings.php files for the variable.

IMHO u should go for updating wordpress application for blog.

susen
May 8 '07 #7

Motoma
Expert 2.5K+
P: 3,235
You may want to try setting your query to: "SELECT cat_id, cat_name FROM {$wpdb->linkcategories}"
May 9 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.