A non-numeric value encountered
on line number 51 means this line it show me an error non-numeric value
->update('purchase',array('item_qty'=>'item_qty'+$item_qty));
function upd_sales($upd_sales)
{
$item_name=$upd_sales['item_name'];
$item_qty=$upd_sales['item_qty'];
$this->db
->where('item_code', $item_name)
->update('purchase',array('item_qty'=>'item_qty'+$item_qty));
}
Try out this way, you need to write a way in mysql update item quantity
function upd_sales($upd_sales)
{
$item_name=$upd_sales['item_name'];
$item_qty=$upd_sales['item_qty'];
$this->db->where('item_code', $item_name)
->set('item_qty', 'item_qty+'.$item_qty, FALSE);
->update('purchase');
}
This isn't javascript
array('item_qty'=>'item_qty'+$item_qty)
If your trying to concant with the +
that is. Otherwise it doesn't make much sense to add strings. Maybe you wanted this instead
array('item_qty'=>'item_qty'.$item_qty)
With a Dot .
Or maybe you just need the value of it.
array('item_qty'=>$item_qty)
Which is more likely because PHP don't care about the variable type, but the database might and your error says NON-Numeric
so concat will always give you a string which is non-numeric in its type.
You are doing string + numeric instead of math operation
exactly on this line ->update('purchase',array('item_qty'=>'item_qty'+$item_qty));
function upd_sales($upd_sales)
{
$item_name=$upd_sales['item_name'];
$item_qty=$upd_sales['item_qty'];
$this->db
->where('item_code', $item_name)
->update('purchase',array('item_qty'=>$item_qty));
}
function upd_sales($upd_sales)
{
$item_name=$upd_sales['item_name'];
$item_qty=$upd_sales['item_qty'];
$this->db
->where('item_code', $item_name)
->update('purchase',array('item_qty'=>'item_qty'+$item_qty)); //'item_qty is string where as $item_qty in number
}
That is because you are trying to get sum of string and number.
Change your code to
function upd_sales($upd_sales)
{
$item_name=$upd_sales['item_name'];
$item_qty=$upd_sales['item_qty'];
$this->db
->where('item_code', $item_name)
->update('purchase',array('item_qty'=> $item_qty));
}
case $competitor1 : // competitor 1 wins $result = $resultwin1;
$won1 = get_post_meta($competitor1, 'won', true);
update_post_meta($competitor1, 'won', $won1 + 1);
wps_update_history ( $competitor1, 'won', '', $lastIP );
update_post_meta($competitor1, 'lasttimestampbattle', current_time( "timestamp" ) );
$lost2 = get_post_meta($competitor2, 'lost', true);
update_post_meta($competitor2, 'lost', $lost2 + 1);
wps_update_history ( $competitor2, 'lost', '', $lastIP );
if ($haswon != "") {
// get actual post title
$postdata = get_post($competitor1);
if ( strlen ( $postdata->post_title ) > 0 )
$result = $postdata->post_title . " " . $haswon;
}
break;