Welcome Guest, Not a member yet? Register   Sign In
bug for multi insert for single mysql query
#1

database structure >> table (game_odds) >> fields (ID_MATCH) (BANKER) (SME)


query data here

$q = "

INSERT INTO game_odds ( ID_MATCH, BANKER, SME )
SELECT * FROM (
SELECT '1553203', '1', 'S') AS tmp 
WHERE NOT EXISTS (
SELECT ID_MATCH FROM  game_odds
WHERE ID_MATCH = '1553203' AND SME = 'S'  AND BANKER = '1'
) LIMIT 1;

INSERT INTO game_odds ( ID_MATCH, BANKER, SME ) 
SELECT * FROM (
SELECT '1553203', '3',  S' ) AS tmp
WHERE NOT EXISTS (
SELECT ID_MATCH FROM game_odds
WHERE ID_MATCH = '1553203' AND SME = 'S' AND BANKER = '3'
) LIMIT 1;


";

this->db->query($sq);




========================================
statement run unsuccessful,  it will show

A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /var/www/ball/application/controllers/Get.php:158)
Filename: core/Common.php
Line Number: 570
Backtrace:
File: /var/www/ball/application/controllers/Get.php
Line: 241
Function: query

File: /var/www/ball/index.php
Line: 315
Function: require_once
Reply
#2

Not likely a bug. The error message suggests that headers have already been set, perhaps inadvertently.
Check that none of the source code files you refer to (even indirectly) have closing PHP tags with white space after them.
Reply
#3

(02-10-2019, 02:11 PM)ciadmin Wrote: Not likely a bug. The error message suggests that headers have already been set, perhaps inadvertently.
Check that none of the source code files you refer to (even indirectly) have closing PHP tags with white space after them.

it will success if i sent one only
Reply
#4

Hmmm. Need more info.

Which version of CI are you using?
Line 158 of your Get controller is the "this->db->query($sq);" shown? and it is using the query string shown above that, even though it is assigned to a different variable, $q?
The error message is the only output from the request?
Does anything get inserted into the database?
Reply
#5

(02-10-2019, 03:59 PM)ciadmin Wrote: Hmmm. Need more info.

Which version of CI are you using?
Line 158 of your Get controller is the "this->db->query($sq);" shown? and it is using the query string shown above that, even though it is assigned to a different variable, $q?
The error message is the only output from the request?
Does anything get inserted into the database?

CodeIgniter Version is 3.1.10
yes, $q / $sq they are the same variable

 the website link here
http://non.asuscomm.com/ball/get/test1
http://non.asuscomm.com/ball/get/test2


codes here
[Image: 8xiCWDEzaR5u8LU1tS7tQ6_h8rmxGa95_cRyHPFR...13-h707-no]
Reply
#6

(This post was last modified: 02-11-2019, 04:55 PM by John_Betong.)

Further to @ciadmin's post...

I just answered a similar topic on another forum:

Please check the PHP Online User Manual regarding the correct usage of header(…)

https://secure.php.net/manual/en/function.header.php

$res = $db->getResult();

// FOLLOWNG LINE IS NOT ALLOWED BEFORE CALLING header(...)

echo $q ."\n<br>";


Also PHP has excellent error checking and reporting which can be set by using the following:
<?php
declare(strict_types=1);
// best removed if online
error_reporting(-1);
ini_set('display_errors', 'true');
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

// your script
Reply
#7

this is not working.

i had clean install a new codeigniter environment.
Now fix the header error.
but still had mysql problem.
it affect the statement can't running.

http://non.asuscomm.com/stock/abc

====================================
public function test1()        <==== failed
{
$q =   "INSERT INTO test ( a, b, c ) VALUES ( '1', '2', '3' );

           INSERT INTO test ( a, b, c ) VALUES ( '4', '5', '6' ); ";

$this->db->query($q);
echo $q;
}


====================================
public function test2()       <==== successed
{
$q =   "INSERT INTO test ( a, b, c ) VALUES ( '1', '2', '3' ); ";

$this->db->query($q);
echo "<pre>".$q;

$q1 =  "INSERT INTO test ( a, b, c ) VALUES ( '4', '5', '6' ); ";

$this->db->query($q1);
echo $q1."</pre>";
}
Reply
#8

I would not call it a bug, instead check your file path and configure the environment variables if possible.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB