View Single Post
  #1  
Old 11-16-2017, 11:11 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vBulletin 4.2.5 Nightmare: MySQLi destroyed Sidebar Custom Code.

My brother is designed MySQL code for the sidebar to our site.

All was wonderful, for many years ...

Then, we 'upgraded' from vBulletin 4.2.2 (which ran the MySQL code we put together)
... but now the vBulletin 4.2.5. (and our new webhost) runs MySQLi ... and we have no idea how to get our side carts functional again. Here is our (failed) attempt to re-do the code:

Code:
$local_dev = FALSE;
   if ($local_dev) { echo "<link rel='stylesheet' type='text/css' href='styles/additional.css' />"; }
   if ($local_dev==TRUE) {
      
      // Establish a Local MySQL connection
      $host = 'localhost:3306';
      $user = 'xxxxxxx';
      $pass = 'xxxxxxx';
      $con = mysqli_connect($host,$user,$pass,TRUE);
      $con_user = mysqli_connect($host,$user,$pass,TRUE);
      $con_tol =  mysqli_connect($host,$user,$pass,TRUE);
      
      // User Identity Variables
      $user_id = 2;
      $usergroupid = 5;
      $security_token = 0;    

      // Website configurations     
      $baseurl = "localhost/macrophoto/";
      
   } else {

      // database connection: macrophoto 
      $host = 'localhost';
      $user = 'xxxxxxx';
      $pass = 'xxxxxxx';
      $con = mysqli_connect($host,$user,$pass,TRUE);

      // database connection: Forum database
      $host = 'localhost';
      $user = 'xxxxxxx';
      $pass = 'xxxxxxx';
      $con_user = mysqli_connect($host,$user,$pass,TRUE);
      
         // database connection: treeoflife
         $host = 'localhost';
         $user = 'xxxxxxx';
         $pass = 'xxxxxxx';
         $con_tol = mysqli_connect($host,$user,$pass,TRUE);

      // Website configurations     
      $baseurl = "www.thenaturephotographer.club";
   }
   $SQL_QRY = "
      SELECT
         pic_id, pic_user_id, pic_folder, pic_title, pic_subtitle
      FROM
         xxxxxxx.xxxxxxx
      WHERE
         pic_folder>1
      ORDER BY pic_uploaded DESC
      LIMIT 0,5
   ";
   $result = mysqli_query($SQL_QRY, $con);
   $cart = "<table  style='margin-top:10px;' width='100%' >";
   $i = 0;
   while ($row=mysqli_fetch_array($result)){
      
      $i++;
      
      // grab the data
      $pic_id = $row["pic_id"];
      $user_id = $row["pic_user_id"];
      $folder_id = $row["pic_folder"];
      $title = $row["pic_title"];
      $subtitle = $row["pic_subtitle"];
      if (!empty($subtitle)) { $title = "$title ($subtitle)"; }
      
      $size = "tiny";
      $url_mosaic          = "http://$baseurl"."image_mosaic.php";
      
      // Get the images
      $field = "pic_path";
      $path = "'thumbnails/', pic_user_id, '/', "; 
      $SQL_QRY = "SELECT concat($path"."pic_user_id, '_thumb_', LPAD(pic_id, 10, '0'), '_$size.', pic_ext ) as '$field' FROM macrophoto.pics WHERE pic_id=$pic_id";
      $result2 = mysql_query($SQL_QRY, $con);
      $row = mysqli_fetch_array($result2);
      $img_path = $row[$field];
      $size = getimagesize($img_path);
      $width = $size[0];
      $height = $size[1];
      
      // Username
      $field = "username"; 
      $SQL_QRY = "SELECT $field FROM natureforum.vbuser WHERE userid=$user_id";
      $value_result = mysqli_query($SQL_QRY, $con_user);
      if ($value_result != NULL ) {
         $row = mysqli_fetch_array($value_result);
         $user_name = $row[$field];
      } else {
         $user_name = "";
      }     
      
      // Avatar
      $field = "avatarrevision";
      $SQL_QRY = "SELECT $field FROM natureforum.vbuser WHERE userid='$user_id'";
      $result3 = mysqli_query($SQL_QRY, $con_user);
      $row = mysqli_fetch_array($result3);
      $av_idx = $row[$field];
      $avatar_path = "./customavatars/thumbs/avatar$user_id"."_$av_idx.gif";
      if (!file_exists($avatar_path)) { $avatar_path = "./images/misc/unknown.gif"; }
      $avatar = "<img style='width=100%;max-width:30px;' src='$avatar_path'>";
      $profile_url = "member.php?$user_id";
      $avatar = "<a href='$profile_url' target='profile' title='$user_name'>$avatar</a>";

      // Get a Link to the View page
      if ($local_dev) {
         $view_path = "$baseurl"."image_view.php?username=$user_name&folder_id=$folder_id&pic_id=$pic_id&thumb_size=$size";
      } else {
         $view_path = "$user_name/$folder_id/$pic_id";
      }
      
      if ($width>$height) { $measure="width"; } else { $measure="height"; }
      $img = "<img style='$measure:100%;min-$measure:200px;max-$measure:210px;box-shadow: 5px 5px 5px #1c1d1f;margin-bottom:15px;margin-left:10px;' src='$img_path' title='$title'>";
      $link = "<a href='$view_path' target='view'>$img</a>";
      $user = "<font size='-1'><a href='$url_mosaic?user_id=$user_id' target='user'>$user_name</a></font>";
      
      if ($i==5) {$px = "0px";}  else { $px="1px"; }
      
      $cart .= "<tr' ><td style='padding-top:5px;border-bottom:$px dotted;' align='left' valign='top' width='10%' >$avatar</td><td style='padding-top:5px;border-bottom:$px dotted;' valign='middle' align='center' >$link</td></tr>";
            
   }
   $cart .= "</table>";
return $cart;



Can anyone please point out our coding errors?

Would be very grateful!
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01246 seconds
  • Memory Usage 1,791KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete