vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   vBulletin 4.2.5 Nightmare: MySQLi destroyed Sidebar Custom Code. (https://vborg.vbsupport.ru/showthread.php?t=325775)

MacroPhotoPro 11-16-2017 11:11 PM

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!

Dave 11-17-2017 12:38 AM

Take a look at https://www.phpclasses.org/blog/pack...to-MySQLi.html

MacroPhotoPro 11-17-2017 01:27 PM

Thanks, Dave, I will try!

Dead Eddie 11-17-2017 08:12 PM

I noticed this:

PHP Code:

$result2 mysql_query($SQL_QRY$con); 

;)

MacroPhotoPro 11-17-2017 08:31 PM

Thanks :)


All times are GMT. The time now is 12:38 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01104 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete