troubleshooting Question

php move from windows to web hosting linux

Avatar of teera
teera asked on
PHPMySQL Server
6 Comments3 Solutions337 ViewsLast Modified:
the code below is work when i run on windows i up load to my site it show this error
but    'kohsamui_asian'@'localhost'  can delete and select sale table


SELECT command denied to user 'kohsamui_asian'@'localhost' for table 'sale'

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
session_start();
require_once('../Connections/aoldatabase.php');
mysql_select_db($database_aoldatabase, $aoldatabase);
$vat = 7 ;
$Discount = 0;
$invoiceno =  $_SESSION['invoiceno'];

$showsale = " select * from sale where preselRef  = '$invoiceno' ";
$salequery =mysql_query ($showsale)
    or die ("Query '$query' failed with error message: \"" . mysql_error () . '"');
 
$row_salequery = mysql_fetch_assoc($salequery);
$reDiscount = $row_salequery['distcount']; 
if ($reDiscount>0)
{
$Discount = $reDiscount ;
}



if (isset($_POST['invoiceType']))
{
$invoicetype = $_POST['invoiceType'] ;
if ($invoicetype == 'i')
{
            $query_slelectPresell = "SELECT presell.refid, presell.productcode, presell.qutiy, presell.price,presell.qutiy*presell.price, presell.productname            FROM presell where presell.refid = $invoiceno ORDER BY `presell`.`timestamp` ASC";
            $slelectPresell = mysql_query($query_slelectPresell, $aoldatabase) or die(mysql_error());
            $row_slelectPresell = mysql_fetch_assoc($slelectPresell);
            $totalRows_slelectPresell = mysql_num_rows($slelectPresell);
            ?>
     
             <table width="906" height="121" border="1">
                  <tr>
                        <td width="80" height="37"></td>
                        <td width="136">CODE</td>
                        <td width="108">NAME</td>
                         <td width="108">Quantity</td>
                         <td width="108">Uprice</td>
                        <td width="160">Total</td>
                         
                  </tr>
                   <?php
                        $totqutiy = 0  ;
                        $toPay = 0  ;
                        $noorder = 0  ;

                   do { ?>
                  <tr>
                        <?php $totqutiy = $totqutiy+$row_slelectPresell['qutiy']  ;
                        $toPay = $toPay+$row_slelectPresell['presell.qutiy*presell.price']  ;
                        $noorder = $noorder + 1 ;
                         ?>
                 <td height="32"><?php echo $noorder ; ?></td>
                 <td><?php echo $row_slelectPresell['productcode']; ?></td>
                 <td><?php echo  substr($row_slelectPresell['productname'], 0, 30); ?></td>
                <td><?php echo $row_slelectPresell['qutiy']; ?></td>
                <td align="right"><?php echo  number_format($row_slelectPresell['price'], 2, '.', ','); ?></td>
                 <td align="right"><?php echo  number_format($row_slelectPresell['presell.qutiy*presell.price'], 2, '.', ',');   $row_slelectPresell['presell.qutiy*presell.price']; ?></td>
                
                     </tr>
                     <?php } while ($row_slelectPresell = mysql_fetch_assoc($slelectPresell)); ?>
                <tr>
                <td width="80" height="42"></td>
                <td width="136">&nbsp;</td>
                 <td width="108">&nbsp;</td>
                 <td width="108"><?php echo $totqutiy; ?></td>
                 <td width="108">total </td>
				 <?php $toPay= $toPay-$Discount ?>
                 <td width="160" align="right"><?php echo number_format($toPay/1.07 , 2, '.', ',') ;
                 $beforevat = number_format($toPay/1.07 , 2, '.', '');
                 $beforevatin = str_replace(",","",$beforevat);
                 
                 ?></td>
                
                     </tr>
                     <tr>
                 <td width="80" height="42"></td>
                 <td width="136">&nbsp;</td>
                  <td width="108">&nbsp;</td>
                  <td width="108">&nbsp;</td>
                 <td width="108">VAT </td>
                 <td width="160" align="right"><?php echo number_format(($toPay - $beforevat) , 2, '.', ',')  ;

                 $vatcost = number_format(($toPay - $beforevat) , 2, '.', ',') ;
                 $vatcostin = str_replace(",","",$vatcost);
                 ?></td>
                
                     </tr>
                     <tr>
                 <td width="80" height="42"></td>
                 <td width="136">&nbsp;</td>
                 <td width="108">&nbsp;</td>
                 <td width="108">&nbsp;</td>
                 <td width="108">Grand total </td>
                 <td width="160" align="right"><?php echo number_format($toPay, 2, '.', ',')  ;
                  $grandtotal = number_format($toPay, 2, '.', ',')  ;
                  $grandtotalin = str_replace(",","",$grandtotal );  ?></td>
                
                     </tr>
                    
                   </table>


                        <?php
                        echo " test $beforevatin   s  $vatcostin  ss  $grandtotalin  " ;
//                        $query_salehead  = "UPDATE `sale` SET `total`= $beforevat, `vatinbill`= $vatcost , `grandtotal`= $grandtotal , `invoicetype`= 'i'  WHERE (`preselRef`='$invoiceno'  )  " ;
//                        $salehead = mysql_query($query_salehead, $aoldatabase) or die(mysql_error());
                        $query_salehead  = "UPDATE `sale` SET `total`= $beforevatin, `vatinbill`= $vatcostin , `grandtotal`= $grandtotalin , `invoicetype`= 'i'  WHERE `preselRef`= $invoiceno   " ;
                        $salehead = mysql_query($query_salehead, $aoldatabase) or die(mysql_error());
                        mysql_free_result($slelectPresell);
                        
                        $query_maxid = "SELECT  MAX(sale.secid)as rmax FROM asianonline.sale WHERE `invoicetype`= 'i'" ;
                $saleRmax = mysql_query($query_maxid, $aoldatabase) or die(mysql_error());
                while ($query_max= mysql_fetch_row($saleRmax))
                {
                      echo $query_max[0];
                      $maxidu = $query_max[0]+1 ;
                      }
                               
                 $upsalecid = "UPDATE `asianonline`.`sale` SET `secid` = '$maxidu' WHERE `sale`.`preselRef` ='$invoiceno' LIMIT 1 ";
                 $upsalecid_q = mysql_query($upsalecid, $aoldatabase) or die(mysql_error());
                
                     
//               echo "<meta http-equiv=\"refresh\" content=\"0;url=presalefromS6.php\" />\n";
               echo "<meta http-equiv=\"refresh\" content=\"0;url=../invoice.php\" />\n";
                 exit();  

// above invoice ==  i
}

if ($invoicetype == 'r')
{
       
            $query_slelectPresell = "SELECT presell.refid, presell.productcode, presell.qutiy, presell.price,presell.qutiy*presell.price, presell.productname            FROM presell where presell.refid = $invoiceno ORDER BY `presell`.`timestamp` ASC";
            $slelectPresell = mysql_query($query_slelectPresell, $aoldatabase) or die(mysql_error());
            $row_slelectPresell = mysql_fetch_assoc($slelectPresell);
            $totalRows_slelectPresell = mysql_num_rows($slelectPresell);
            ?>
     
             <table width="906" height="121" border="1">
                  <tr>
                        <td width="80" height="37"></td>
                        <td width="136">CODE</td>
                        <td width="108">NAME</td>
                         <td width="108">Quantity</td>
                         <td width="108">Uprice</td>
                        <td width="160">Total</td>
                         
                  </tr>
                   <?php
                        $totqutiy = 0  ;
                        $toPay = 0  ;
                        $noorder = 0  ;

                   do { ?>
                  <tr>
                        <?php $totqutiy = $totqutiy+$row_slelectPresell['qutiy']  ;
                        $toPay = $toPay+$row_slelectPresell['presell.qutiy*presell.price']  ;
                        $noorder = $noorder + 1 ;
                        
                         ?>
                 <td height="32"><?php echo $noorder ; ?></td>
                 <td><?php echo $row_slelectPresell['productcode']; ?></td>
                 <td><?php echo  substr($row_slelectPresell['productname'], 0, 30); ?></td>
                <td><?php echo $row_slelectPresell['qutiy']; ?></td>
                <td align="right"><?php echo  number_format($row_slelectPresell['price'], 2, '.', ','); ?></td>
                 <td align="right"><?php echo  number_format($row_slelectPresell['presell.qutiy*presell.price'], 2, '.', ',');   $row_slelectPresell['presell.qutiy*presell.price']; ?></td>
                
                     </tr>
                     <?php } while ($row_slelectPresell = mysql_fetch_assoc($slelectPresell)); ?>
 
 
                     <tr>
                 <td width="80" height="42"></td>
                 <td width="136">&nbsp;</td>
                 <td width="108">&nbsp;</td>
                 <td width="108">&nbsp;</td>
				<?php $receivepay = $toPay-$Discount?> ;

			    ?>
                 <td width="108">Grand total </td>
                 <td width="160" align="right"><?php echo number_format($toPay, 2, '.', ',')  ;
                  $grandtotal = number_format($toPay, 2, '.', ',')  ; ?></td>
                
                     </tr>
                    
                   </table>


                        <?php
                        
                        $query_salehead  = "UPDATE `sale` SET `total`= $receivepay, `vatinbill`= '0' , `grandtotal`= $receivepay , `invoicetype`= 'r'  WHERE (`preselRef`=$invoiceno )  " ;
                        $salehead = mysql_query($query_salehead, $aoldatabase) or die(mysql_error());
                        mysql_free_result($slelectPresell);
                        
/*                       $query_updatemaxid = "SELECT @max_value:=MAX(sale.secid)+1
                FROM  asianonline.sale WHERE `invoicetype`= 'r';                        
                UPDATE `asianonline`.`sale` SET `secid` = '@max_value' WHERE `sale`.`preselRef` ='$invoiceno' LIMIT 1; ";
               
                $salehead = mysql_query($query_updatemaxid, $aoldatabase) or die(mysql_error());
 */              
               
                $query_maxid = "SELECT  MAX(sale.secid)as rmax FROM asianonline.sale WHERE `invoicetype`= 'r'" ;
                $saleRmax = mysql_query($query_maxid, $aoldatabase) or die(mysql_error());
                while ($query_max= mysql_fetch_row($saleRmax))
                {
                      echo $query_max[0];
                      $maxidu = $query_max[0]+1 ;
                      }
                               
                 $upsalecid = "UPDATE `asianonline`.`sale` SET `secid` = '$maxidu' WHERE `sale`.`preselRef` ='$invoiceno' LIMIT 1 ";
                 $upsalecid_q = mysql_query($upsalecid, $aoldatabase) or die(mysql_error());
				 echo "<meta http-equiv=\"refresh\" content=\"0;url=../presalefromS32.php\" />\n";
                 exit();
                     
// invoice ==  r
}

if ($invoicetype == 'd')
 {
            $query_slelectPresell = "SELECT presell.refid, presell.productcode, presell.qutiy, presell.price,presell.qutiy*presell.price, presell.productname            FROM presell where presell.refid = $invoiceno ORDER BY `presell`.`timestamp` ASC";
            $slelectPresell = mysql_query($query_slelectPresell, $aoldatabase) or die(mysql_error());
            $row_slelectPresell = mysql_fetch_assoc($slelectPresell);
            $totalRows_slelectPresell = mysql_num_rows($slelectPresell);
            ?>
     
             <table width="906" height="121" border="1">
                  <tr>
                        <td width="80" height="37"></td>
                        <td width="136">CODE</td>
                        <td width="108">NAME</td>
                         <td width="108">Quantity</td>
                         <td width="108">Uprice</td>
                        <td width="160">Total</td>
                         
                  </tr>
                   <?php
                        $totqutiy = 0  ;
                        $toPay = 0  ;
                        $noorder = 0  ;
                        

                   do { ?>
                  <tr>
                        <?php $totqutiy = $totqutiy+$row_slelectPresell['qutiy']  ;
                        $toPay = $toPay+$row_slelectPresell['presell.qutiy*presell.price']  ;
                        $noorder = $noorder + 1 ;
                        $receivepay = $toPay;
                         ?>
                 <td height="32"><?php echo $noorder ; ?></td>
                 <td><?php echo $row_slelectPresell['productcode']; ?></td>
                 <td><?php echo  substr($row_slelectPresell['productname'], 0, 30); ?></td>
                <td><?php echo $row_slelectPresell['qutiy']; ?></td>
                <td align="right"><?php echo  number_format($row_slelectPresell['price'], 2, '.', ','); ?></td>
                 <td align="right"><?php echo  number_format($row_slelectPresell['presell.qutiy*presell.price'], 2, '.', ',');   $row_slelectPresell['presell.qutiy*presell.price']; ?></td>
                
                     </tr>
                     <?php } while ($row_slelectPresell = mysql_fetch_assoc($slelectPresell)); ?>

                    
                
                     </tr>
                     <tr>
                 <td width="80" height="42"></td>
                 <td width="136">&nbsp;</td>
                 <td width="108">&nbsp;</td>
                 <td width="108">&nbsp;</td>
				 <?php $receivepay = $toPay-$Discount?> ;
                 <td width="108">Grand total </td>
                 <td width="160" align="right"><?php echo number_format($toPay, 2, '.', ',')  ;
                  $grandtotal = number_format($toPay, 2, '.', ',')  ; ?></td>
                
                     </tr>
                    
                   </table>


                        <?php
                        $query_salehead  = "UPDATE `sale` SET `total`= $receivepay, `vatinbill`= '0', `grandtotal`= $receivepay , `invoicetype`= 'd'  WHERE (`preselRef`= '$invoiceno' )  " ;
                        $salehead = mysql_query($query_salehead, $aoldatabase) or die(mysql_error());
                        mysql_free_result($slelectPresell);
                        
                        $query_maxid = "SELECT  MAX(sale.secid)as rmax FROM asianonline.sale WHERE `invoicetype`= 'd'" ;
                $saleRmax = mysql_query($query_maxid, $aoldatabase) or die(mysql_error());
                while ($query_max= mysql_fetch_row($saleRmax))
                {
                      echo $query_max[0];
                      $maxidu = $query_max[0]+1 ;
                      }
                               
                 $upsalecid = "UPDATE `asianonline`.`sale` SET `secid` = '$maxidu' WHERE `sale`.`preselRef` ='$invoiceno' LIMIT 1 ";
                 $upsalecid_q = mysql_query($upsalecid, $aoldatabase) or die(mysql_error());
                 echo "<meta http-equiv=\"refresh\" content=\"0;url=../presalefromS27.php\" />\n";
                     
                        exit();
// invoice ==  d
}
}

?>

<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
  <p>
    
    <br />
    <label>
      <input type="radio" name="invoiceType" value="r" id="invoiceType_1" />
      receipt</label>
    <br />
    <label>
      <input type="radio" name="invoiceType" value="d" id="invoiceType_2" />
      delivery note</label>
    <br /><input name="InvoiceType" type="submit" value="InvoiceType" />
  </p>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
iliecz

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros