www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to insert calculate values to database

  1. #1
    Join Date
    Jul 2014
    Posts
    12

    Question How to insert calculate values to database

    Hi,
    I'm trying to insert calculate values to DB.this is my code

    PHP Code:
    <?php
    require('dbconnection.php');



    $a=$_POST['a'];
    $b=$_POST['b'];

    class 
    cal{

     
    public function 
    insert($a,$b){

    if(((
    $a)&&($b))!="")
    {
     
    $c=$a*$b;

    $sql "INSERT INTO cropplant (sbetweenQ ,sbetweenC ,sbetweenTC ) VALUES ('$a', '$b', '$c')";
    $query mysql_query($sql);
    if(!
    $query)
            {
                echo 
    '<script type="text/javascript">alert("DB Update error ! please Re-enter your details.");</script>'
            

            }else
                {
                echo 
    '<script type="text/javascript">alert("New Cropplant Added Successfuly.");</script>'
                
            }


    }else{

    echo
    "please enter all";
    }
    }
    }


    ?>
    what is the error in this code.please help me

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    703
    I've seen this before. Where did you copy it from? And what error message are you getting from it? Who says there is an error in this code?
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


    at the top of ALL php code while you develop it!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles