Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 11-17-2017, 12:38 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Take a look at https://www.phpclasses.org/blog/pack...to-MySQLi.html
Reply With Quote
  #3  
Old 11-17-2017, 01:27 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, Dave, I will try!
Reply With Quote
  #4  
Old 11-17-2017, 08:12 PM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I noticed this:

PHP Code:
$result2 mysql_query($SQL_QRY$con); 
Reply With Quote
  #5  
Old 11-17-2017, 08:31 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:46 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03663 seconds
  • Memory Usage 2,205KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete