mysql wordpress php syntax error -


any appreciated

i error in php error logs regarding 1 of sites. have site same setup no errors....

i'm lost on 1

wordpress database error have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1 query select *   wp_cat_banners cat_id= made require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/telegraph-wp-3-1/single.php'), get_header, locate_template, load_template, require_once('/themes/telegraph-wp-3-1/header.php') 

this code....

<? global $wpdb; $cat_id = get_query_var('cat'); if($cat_id!="") { $parent_id=get_top_parent_category((int) $cat_id); } $sql2 = "select *   wp_cat_banners cat_id=$parent_id"; $cc=$wpdb->get_row($sql2, 'array_a'); $background=$cc['background_image']; if($background !="") { ?>   <? global $wpdb; if(is_front_page() || is_page()) { $sql2 = "select *   wp_cat_banners_home id=1"; $cc=$wpdb->get_row($sql2, 'array_a'); $right_banner5=$cc['right_banner5']; if($right_banner5!="") { ?> <div id="bannerhead1"><?php echo $right_banner5; ?></div> <?php } } else { if(is_single()) { $categories= get_the_category();  $cat_id=$categories[0]->cat_id; } else { $cat_id = get_query_var('cat'); } if($cat_id!="") { $parent_id=get_top_parent_category((int) $cat_id); $sql2 = "select *   wp_cat_banners cat_id=$parent_id"; $cc=$wpdb->get_row($sql2, 'array_a'); $right_banner5=$cc['right_banner5']; if($right_banner5!="") { ?> 

$parent_id empty. can fix by:

$cat_id = get_query_var('cat'); if($cat_id!="") {     $parent_id=get_top_parent_category((int) $cat_id);     $sql2 = "select *   wp_cat_banners cat_id=$parent_id"; } else { //else code here } 

this makes sure $parent_id set before calling query. had, query run regardless if $parent_id declared , set; error.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -