*

osclassic

  • ***
  • 34 posts
Need help updating this code from a old plugin
« on: February 27, 2021, 04:45:40 AM »
<?php
$host= osc_db_host();
$username= osc_db_user();
$password= osc_db_password();
$db_name= osc_db_name();
$tbl_name= DB_TABLE_PREFIX."t_region"; // Table name

//Connect to server and select database. - This part below is causing error and will not display regions or update

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if(isset($_POST['checkbox'])){$checkbox = $_POST['checkbox'];
if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"])
$id = "('" . implode( "','", $checkbox ) . "');" ;
$sql="UPDATE $tbl_name SET featured = '".(isset($activate)?'Y':'N')."' WHERE pk_i_id IN $id" ;
$result = mysql_query($sql) or die(mysql_error());
} ?>

*

MB Themes

Re: Need help updating this code from a old plugin
« Reply #1 on: February 27, 2021, 09:41:09 AM »
@osclassic
That is wery old way to query osclass database, I do not believe it is too secure. Here is bit better way to get data quickly.

Code: [Select]
  $conn = DBConnectionClass::newInstance();
  $data = $conn->getOsclassDb();
  $comm = new DBCommandClass($data);
  $db_prefix = DB_TABLE_PREFIX;

  $query = "INSERT INTO {$db_prefix}t_item_veronika (fk_i_item_id) VALUES ({$item['pk_i_id']})";
  $result = $comm->query($query);
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots