who can help me???
for($x=0; $x<$rowsCount; $x++)
{
$sql = "INSERT INTO PRS_TEST
(
NO_KAD_PENGENALAN,
NAMA_PERIBADI,
NO_FAIL_KPM,
KOD_IPT
)
VALUES
(
".$_SESSION['loading']['content'][$x][0].",
'".$_SESSION['loading']['content'][$x][1]."',
'".$_SESSION['loading']['content'][$x][2]."',
'".$_SESSION['loading']['content'][$x][3]."',
'".$_SESSION['loading']['content'][$x][4]."'
)";
$myQuery->query($sql,'RUN');
}
Why when I run this, the output is:
INSERT INTO PRS_TEST (NO_KAD_PENGENALAN,NAMA_PERIBADI,NO_FAIL_KPM,KOD_IPT) VALUES( 843,'SHOB','A01/E520LP/R1','A01')
but it empty in database.. I not echo the statement.
run statement
Moderator: General Moderators
Re: run statement
Easy:
Turn this: "$_SESSION['loading']['content'][$x][0]"
In to this: '$_SESSION[loading][content][$x][0]'
Furthermore, you have specified 4 column names and 5 variable names (0-4 is 5), that will blow it up too.
I hope this helped.
Turn this: "$_SESSION['loading']['content'][$x][0]"
In to this: '$_SESSION[loading][content][$x][0]'
Furthermore, you have specified 4 column names and 5 variable names (0-4 is 5), that will blow it up too.
I hope this helped.
-
kyroolUnwar
- Forum Newbie
- Posts: 4
- Joined: Mon Jan 18, 2010 9:45 pm
Re: run statement
ohh.. thanks.. i already correct that.. but it still not work.. but when I run the sql in database, it will stored the data.. I think the problem cause from $myQuery->query($sql,'RUN');
Re: run statement
kyroolUnwar wrote:ohh.. thanks.. i already correct that.. but it still not work.. but when I run the sql in database, it will stored the data.. I think the problem cause from $myQuery->query($sql,'RUN');
Ah, I didn't notice that at first. try this:
Code: Select all
mysql_query($sql)Code: Select all
#This
$sql = "INSERT INTO PRS_TEST
#Should be this
$sql = "INSERT INTO PRS_TEST";-
kyroolUnwar
- Forum Newbie
- Posts: 4
- Joined: Mon Jan 18, 2010 9:45 pm
Re: run statement
I don't sure, mysql_query($sql) can use for oracle database?
one more thing, my sql statement actually,
$sql = "INSERT INTO PRS_TEST (NO_KAD_PENGENALAN, NAMA_PERIBADI, NO_FAIL_KPM, KOD_IPT ) VALUES (".$_SESSION['loading']['content'][$x][0].",'".$_SESSION['loading']['content'][$x][1]."','".$_SESSION['loading']['content'][$x][2]."','".$_SESSION['loading']['content'][$x][3]."')";
$myQuery->query($sql,'RUN');
I actually familiar to php mysql database, this year, i try to learn php oracle database... it hard to me... I think oracle can do more then mysql can do.. so I try to learn oracle.. but... why this error happen..
one more thing, my sql statement actually,
$sql = "INSERT INTO PRS_TEST (NO_KAD_PENGENALAN, NAMA_PERIBADI, NO_FAIL_KPM, KOD_IPT ) VALUES (".$_SESSION['loading']['content'][$x][0].",'".$_SESSION['loading']['content'][$x][1]."','".$_SESSION['loading']['content'][$x][2]."','".$_SESSION['loading']['content'][$x][3]."')";
$myQuery->query($sql,'RUN');
I actually familiar to php mysql database, this year, i try to learn php oracle database... it hard to me... I think oracle can do more then mysql can do.. so I try to learn oracle.. but... why this error happen..
Re: run statement
I had no idea it was Oracle. Nevermind. It might also be helpful to assign your $_SESSION variables to something more reasonably named. for example: $session1 = "$_SESSION['loading']['content'][$x][2]"kyroolUnwar wrote:I don't sure, mysql_query($sql) can use for oracle database?
one more thing, my sql statement actually,
$sql = "INSERT INTO PRS_TEST (NO_KAD_PENGENALAN, NAMA_PERIBADI, NO_FAIL_KPM, KOD_IPT ) VALUES (".$_SESSION['loading']['content'][$x][0].",'".$_SESSION['loading']['content'][$x][1]."','".$_SESSION['loading']['content'][$x][2]."','".$_SESSION['loading']['content'][$x][3]."')";
$myQuery->query($sql,'RUN');
I actually familiar to php mysql database, this year, i try to learn php oracle database... it hard to me... I think oracle can do more then mysql can do.. so I try to learn oracle.. but... why this error happen..
I see you still have your single quote marks in the wrong place and you also need to eliminate the periods before and after the variable name. So then your SQL statment will be as follows,
Code: Select all
$sql = "INSERT INTO PRS_TEST (NO_KAD_PENGENALAN, NAMA_PERIBADI, NO_FAIL_KPM, KOD_IPT ) VALUES ('$session1', '$session2', '$session3', '$session4')";