Avatar of MrTV
MrTV
Flag for Thailand asked on

php move from windows to web hosting linux

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>

Open in new window

PHPMySQL Server

Avatar of undefined
Last Comment
MrTV

8/22/2022 - Mon
Gary

Make sure you have set the users permissions in MySQL correctly
MrTV

ASKER
I turnucate table sale then it work
SOLUTION
Ray Paseur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
MrTV

ASKER
Thank you
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck