Jump to content
sheepiedog

Convert old ms2.2 addon for 2.3.4 admin

Recommended Posts

I am working on a 234bs test store to replace my old ms2.2 store.  I am trying to convert some old addons that I cant live without and I have been successful for the most part but I have run into an issue I am not sure how to correctly solve it. Running php 5.3 and mysql 5.5

 

Add on Update Price with search - http://addons.oscommerce.com/info/1204- absolutely love this addon and use it all the time.  I know there are other similarish add ons - but this one does by search and is so simple and I would like to stay with this one.

 

When I tried to convert it to 2.3.4 admin and run it -  I receive this error :

 

Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/sales/public_html/234bs/admin/price_update.php on line 26

 

This is line 26 :

$sql3 = mysqli_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");

I changed the original mysql to mysqli - but it looks like I also need to reformat the line into 2 sections and I am not sure how to go about that.....

 

Would someone would be able to tell me how to solve this ?

 

 

Share this post


Link to post
Share on other sites

I'm sorry, I dont know what you mean.  I am just learning how to convert these.  Could you explain exactly what it should be or what information I need to find ?

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Thanks !  I tried different combinations in the file I need to convert, the errors are now gone, but the file doesnt work.  Its a standalone file, no changes to core files.  It does a search by either product or model code and the resulting screen allows you to change the price for the search items. I am not even getting the resulting screen.   The report works great on my old ms2.2 store so I wouldnt think it is a php/mysql issue.  Below is the complete file price_update.php - can anyone spot what I need to change to have the report/tool work with 2.3.4 ?

<?php
/*
  $Id: aumento_search.php,v 1.29 2003/04/28 15:32:22 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce

  Author: michele gobbi
  email: michele.gobbi@inwind.it
  
  Released under the GNU General Public License
*/

  require('includes/application_top.php');
  require(DIR_WS_INCLUDES . 'template_top.php');

  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();




// category drop down
$sql3 = tep_db_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");







?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<style type="text/css">
<!--
th {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; background-color: #eeeeee}
/*table {  border: #666666; border-style: dashed; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}*/
/*td {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px}*/
td.left {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; padding-top: 3px; padding-bottom: 3px; padding-left: 5px; text-align: right; padding-right: 16px}

-->
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
         </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo "Quick Price Update" ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left">
<?
if ($action == "search") {
    echo "<form name=\"update\" method=\"post\" action=\"".$_SERVER["PHP_SELF"]."?action=update_prices\">";
    echo "<table>";
    echo "<tr><th>Product ID</th><th>Title</th><th>Price</th></tr><tr>";
    $result = mysql_query("SELECT * FROM products, products_description  WHERE (products.products_model like '%$search%' OR products_description.products_name like '%$search%') AND products.products_id = products_description.products_id");
    if ($row = mysql_fetch_array($result)) {
        do {
            $prezzo=round($row['products_price'],2);
            echo "<td align=\"center\">".$row["products_model"]."</td>\n";
            echo "<td>".$row["products_name"]."</td>\n";
            echo "<td align=\"center\"><input type=\"text\" name=\"product_new_price[".$row['products_id']."]\" value=\"$prezzo\"></td>\n";
            echo "</tr>\n";
        }
        while($row = mysql_fetch_array($result));
    }
    echo "</table>\n";
    echo "<br><input type=\"submit\" value=\"Update the prices\">";
    echo "</form><br><hr><br>";
}
if ($action == "update_prices") {
    foreach($HTTP_POST_VARS['product_new_price'] as $id => $new_price) {
        mysql_query("UPDATE products SET products_price=$new_price WHERE products_id=$id");
    }
    $random = date("U");
    echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>Prezzi aggiornati!!</b></font></p>";
}

?>
        <form name="update" method="post" action="<?=$_SERVER["PHP_SELF"]?>?action=search">
          <table>
            <tr> 
              <th colspan="2">Which product do you want to search for?</td>
            </tr>
            <tr> 
              <td colspan="2"><br></td>
            </tr>
            <tr>
              <td>
                Product or Model Number:
              </td>
              <td>
                <input type="text" name="search">
              </td>
            </tr>
            <tr>
              <td>
              </td>
              <td>
                <input type="submit" value="Search">
              </td>
            </tr>
          </table>
        </form>
        </td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Share this post


Link to post
Share on other sites

@@sheepiedog

 

Did you try changing some of the other places that use mysql_query?   I see it being used in at least two other places.

 

Dan

Share this post


Link to post
Share on other sites

@Mention

 

Thanks - yes, I tried replacing with tep_db and also mysqli in different combinations and it then resulted in errors.  The way I have it above, there are no errors being reported, but it doesnt give any results either.  I have also tried to change one of the  'post' to 'get', no luck.  I obviously dont know enough about the proper coding, but I have been trying to research and learn, thinking it is just a little file, it must be able to be fixed for 2.3.4.

Share this post


Link to post
Share on other sites

You can use easypopulate for this. That's probably the reason this addon has not been updated in years.

Share this post


Link to post
Share on other sites

Yes i have easypopulate, and I use it, but this is an even quicker way to update prices within seconds and I really like it and would like to continue using it. The add on didnt need to be updated for ms2.2 as it worked perfectly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×