We help IT Professionals succeed at work.

php move from windows to web hosting linux

teera
teera asked
on
334 Views
Last Modified: 2012-06-27
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

Comment
Watch Question

CERTIFIED EXPERT
Expert of the Year 2014
Top Expert 2014

Commented:
Make sure you have set the users permissions in MySQL correctly

Author

Commented:
I turnucate table sale then it work
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.