[RELEASE] `Furniture` to `Items_Base` Converter

Ptsface12

New Member
Aug 19, 2011
19
2
Hi guys,
BEFORE YOU POST: I know this has already been released before. However, I got alot of errors with it (although I was probably doing something wrong, but hey-ho). Also, this script was written with MySQLi as the MySQL functions are decapitated.

Code:
<?php
$user = "root";
$pass = "whatever";
$db = "lol";
$host = "localhost";
 
$link = mysqli_connect($host, $user, $pass, $db) or die("Error " . mysqli_error($link));
$query = "SELECT * FROM furniture";
$result = $link->query($query);
 
$appendstring = "INSERT IGNORE INTO `items_base` (`item_id`, `sprite_id`, `public_name`, `item_name`, `type`, `width`, `length`, `height`, `allow_stack`, `allow_walk`, `allow_sit`, `allow_recycle`, `allow_trade`, `allow_marketplace_sell`, `allow_gift`, `allow_inventory_stack`, `interaction_type`, `cycle_count`, `vending_ids`) VALUES ";
 
while($row = mysqli_fetch_array($result)) {
  $itemid =  str_replace("'","", $row["id"]);
  $name = str_replace("'","", $row["public_name"]);
  $itemname = str_replace("'","", $row["item_name"]);
  $type = str_replace("'","", $row["type"]);
  $spriteid = str_replace("'","", $row["sprite_id"]);
  $width = str_replace("'","", $row["width"]);
  $length = str_replace("'","", $row["length"]);
  $height = str_replace("'","", $row["stack_height"]);
  $stack = str_replace("'","", $row["can_stack"]);
  $walk = str_replace("'","", $row["is_walkable"]);
  $sit = str_replace("'","", $row["can_sit"]);
  $recycle = str_replace("'","", $row["allow_recycle"]);
  $trade = str_replace("'","", $row["allow_trade"]);
  $sell = str_replace("'","", $row["allow_marketplace_sell"]);
  $gift = str_replace("'","", $row["allow_gift"]);
  $stack = str_replace("'","", $row["allow_inventory_stack"]);
  $cycle = str_replace("'","", $row["interaction_modes_count"]);
  $interaction = str_replace("'","", $row["interaction_type"]);
  $vendid = str_replace("'","", $row["vending_ids"]);
 
  $appendstring = $appendstring ."('" . $itemid . "', '" . $spriteid . "', '" . $name . "', '" . $itemname . "', '" . $type . "','" . $width . "','" . $length . "','" . $height . "','" . $stack . "','" . $walk . "','" . $sit ."','" . $recycle . "','" . $trade . "','" . $marketplace . "','" . $gift . "','" . $stack . "','" . $interaction . "','" . $cycle . "','" . $vendid . "'),</br>";
}
 
echo substr_replace($appendstring, ";", -6);
?>

Save it as base.php.

1. Put this file in your directory folder e.g (wwwroot or htdocs).
2. Replace the details within the file to your; MySQL username, password, database and host (most likely still localhost).
3. Go to
4. Copy your SQL data and go ahead and paste it as an SQL query and it should work.

With this version, you don't need to remove the comma at the end and replace it with the colon. ALSO if you tried running this as a query in navicat and got duplicate key errors, this will be bypassed by the 'INSERT IGNORE INTO' statement in the sql query.

If you have any issues with this and/or you can't get it to work. Reply with your issue and i'll try my best to help you.

Credits:
Me 80%
20% to whoever made the furniture and items_base.

Thanks.
 

Ptsface12

New Member
Aug 19, 2011
19
2
Uhh, did I really? Considering you really can't spell and you know nothing about me, you have no opinion. I coded this script, thank you very much. If you had seen, I also created some others; but it's dumb shit's like you, that de-motivates me to create more of them.
 

Users who are viewing this thread

Top