Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Error Query in PHP

08 Sep 2018   #1
happy memorial

Windows 10 x64
 
 
Error Query in PHP

I've got this error in php

Error Query [insert into priv_qualification (nokp,qualification_type,qualification,awarding_body,qualification_date,gezzette_date,experience,q_d oc) VALUES (:a1,:b1,:c1,:d1,:e1,:f1,:g1,:h1)]

and this is my coding

$strSQL = ("insert into peribadi_details (nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES (:b,:c,:d,:e,:f,:g,:h,:i,:j)");
$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysqli_num_rows($objQuery);

HELP ME PLEASE


My System SpecsSystem Spec
.
09 Sep 2018   #2
lehnerus2000

W7 Ultimate SP1, LM18.3 MATE, W10 Home, #All 64 bit
 
 
Weird

I'm not sure how the query and error message are related.

They seem to be about 2 different tables ("priv_qualification" vs "peribadi_details") with a different number of values (8 vs 9).

I assume that ":a1,:b1, etc." are some type of variables, but we never used that format in my PHP courses.
My System SpecsSystem Spec
09 Sep 2018   #3
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi happy memorial, is there any additional information that you could give us that might help?
My System SpecsSystem Spec
.

10 Sep 2018   #4
happy memorial

Windows 10 x64
 
 

I've changes the coding like this

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name=test_input($_POST['name']);
$nokp=test_input($_POST['nokp']);
$homeadd=test_input($_POST['homeadd']);


$teleoff=test_input($_POST['teleoff']);
$restele=test_input($_POST['restele']);
$mobiletele=test_input($_POST['mobiletele']);
$position=test_input($_POST['position']);
$grade=test_input($_POST['gred']);
$serviceduration=test_input($_POST['serviceduration']);
}


$name=$_POST['name'];
$nokp=$_POST['nokp'];
$homeadd=$_POST['homeadd'];
$teleoff=$_POST['teleoff'];
$restele=$_POST['restele'];
$mobiletele=$_POST['mobiletele'];
$position=$_POST['position'];
$grade=$_POST['grade'];
$serviceduration=$_POST['serviceduration'];
$mohappt=$_POST['mohappt'];


$t_t = $_POST["mohappt"];
$hari=substr("$t_t",0,2); $bulan=substr("$t_t",3,2); $tahun=substr("$t_t",6,4);
$mohappt="$tahun"."-"."$bulan"."-"."$hari";
//$mohappt=$_POST['mohappt'];

$strSQL = "SELECT * FROM peribadi_details WHERE nokp = '".$nokp."'";


$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$checkavailable = mysqli_fetch_array ($objQuery);

if($checkavailable==1) {


$stmt="update peribadi,peribadi_details set namapegawai='$name',nokp=$nokp,homeadd1='$homeadd',officephone='$teleoff',homephone='$restele',mobil ephone='$mobiletele',position='$position',grade=$grade,serviceduration=$serviceduration,mohappointme nt='$mohappt' WHERE peribadi.nokp=peribadi_details.nokp AND peribadi.nokp='$nokp'";


$objQuery = mysqli_query($conn,$stmt) or die ("Error Query [".$stmt."]");
$Num_Rows = mysqli_num_rows($objQuery);

}
else {

$a = $_POST['name'];
$b = $_POST['nokp'];
$c = $_POST['homeadd'];
$d = $_POST['teleoff'];
$e = $_POST['restele'];
$f = $_POST['mobiletele'];
$g = $_POST['position'];
$h = $_POST['grade'];
$i = $_POST['serviceduration'];
$j = $_POST['mohappt'];

$strSQL = "insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j)";
$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysqli_num_rows($objQuery);

echo "New records created successfully";

}
}


and the error came out like this

Error Query [insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES (GURVINDERJEET KAUR A/P SARJIT SINGH,870828565466,selayang,06-303456,727363,0112332143,Consultant,,,21-09-2018)]
My System SpecsSystem Spec
10 Sep 2018   #5
happy memorial

Windows 10 x64
 
 
still error

I've changed the coding like this

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name=test_input($_POST['name']);
$nokp=test_input($_POST['nokp']);
$homeadd=test_input($_POST['homeadd']);


$teleoff=test_input($_POST['teleoff']);
$restele=test_input($_POST['restele']);
$mobiletele=test_input($_POST['mobiletele']);
$position=test_input($_POST['position']);
$grade=test_input($_POST['gred']);
$serviceduration=test_input($_POST['serviceduration']);
}


$name=$_POST['name'];
$nokp=$_POST['nokp'];
$homeadd=$_POST['homeadd'];
$teleoff=$_POST['teleoff'];
$restele=$_POST['restele'];
$mobiletele=$_POST['mobiletele'];
$position=$_POST['position'];
$grade=$_POST['grade'];
$serviceduration=$_POST['serviceduration'];
$mohappt=$_POST['mohappt'];


$t_t = $_POST["mohappt"];
$hari=substr("$t_t",0,2); $bulan=substr("$t_t",3,2); $tahun=substr("$t_t",6,4);
$mohappt="$tahun"."-"."$bulan"."-"."$hari";
//$mohappt=$_POST['mohappt'];

$strSQL = "SELECT * FROM peribadi_details WHERE nokp = '".$nokp."'";


$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$checkavailable = mysqli_fetch_array ($objQuery);

if($checkavailable==1) {


$stmt="update peribadi,peribadi_details set namapegawai='$name',nokp=$nokp,homeadd1='$homeadd',officephone='$teleoff',homephone='$restele',mobil ephone='$mobiletele',position='$position',grade=$grade,serviceduration=$serviceduration,mohappointme nt='$mohappt' WHERE peribadi.nokp=peribadi_details.nokp AND peribadi.nokp='$nokp'";


$objQuery = mysqli_query($conn,$stmt) or die ("Error Query [".$stmt."]");
$Num_Rows = mysqli_num_rows($objQuery);

}
else {

$a = $_POST['name'];
$b = $_POST['nokp'];
$c = $_POST['homeadd'];
$d = $_POST['teleoff'];
$e = $_POST['restele'];
$f = $_POST['mobiletele'];
$g = $_POST['position'];
$h = $_POST['grade'];
$i = $_POST['serviceduration'];
$j = $_POST['mohappt'];

$strSQL = "insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j)";
$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysqli_num_rows($objQuery);


echo "New records created successfully";

}
}

and the error came out like this

Error Query [insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES (GURVINDERJEET KAUR A/P SARJIT SINGH,870828565466,selayang,06-303456,727363,0112332143,Consultant,,,21-09-2018)]
My System SpecsSystem Spec
11 Sep 2018   #6
lehnerus2000

W7 Ultimate SP1, LM18.3 MATE, W10 Home, #All 64 bit
 
 
Matching Data Types?

Are you sure that the values you are trying to insert match the data type(s) of the DB table columns/fields?

For example:
  • Inserting integers into INT fields
  • Strings into TEXT/VARCHAR fields
  • Correct DATE format
Are you inserting the date as a String or Date?

From my course notes:
Quote:
The format of a DATE value is 'YYYY-MM-DD'.
According to ANSI SQL, no other format is allowed.
My System SpecsSystem Spec
11 Sep 2018   #7
happy memorial

Windows 10 x64
 
 

Yes..I'm sure that I inserted the data as format..and the date format I set as Date..but still have this error..
My System SpecsSystem Spec
4 Weeks Ago   #8
lehnerus2000

W7 Ultimate SP1, LM18.3 MATE, W10 Home, #All 64 bit
 
 

Quote   Quote: Originally Posted by happy memorial View Post
Yes..I'm sure that I inserted the data as format..and the date format I set as Date..but still have this error..
Your earlier post mentioned this:
Quote:
Error Query [insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES (GURVINDERJEET KAUR A/P SARJIT SINGH,870828565466,selayang,06-303456,727363,0112332143,Consultant,,,21-09-2018)
From my course notes:
Quote:
The format of a DATE value is 'YYYY-MM-DD'.
According to ANSI SQL, no other format is allowed.
Are you sure that your date is correctly formatted?
The error message seems to indicate that the date is not correct.
It should be 2018-09-21.
My System SpecsSystem Spec
2 Weeks Ago   #9
happy memorial

Windows 10 x64
 
 

thanks..I able to manage it now! meow~~
My System SpecsSystem Spec
Reply

 Error Query in PHP




Thread Tools




Similar help and support threads
Thread Forum
A RAM query
This is going to sound real dumb but I bought what I thought was 2GB of DDR form a US site for $20 now I should have read the ad a bit more carefully but whats done is done. What I would like to know though is why does high density RAM not work the same as low density I always thought RAM was...
Hardware & Devices
PSU Query
i have an old PSU that i've been using for probably a decade. It works fine and better than an EZCool 500w that was useless despite costing my 50. So the question is, i'm trying to unlock my Athlon2 X3 450 3.2Ghz using my Biostar a880g+ mainboard and it wont do it. Do you think upgrading the...
Hardware & Devices
RAM query
Mate who hasn't much money came to me with his desktop a "getting on" Compaq Presario SN5540AN with an AMD Athlon dual core 5400+ 2.8Ghz Vista (+SP2). He said to me saying that everything they tried to open prompted a you have a virus message and nothing would open. Usual sort of clean up ...
Hardware & Devices
Handbrake Query Parcer Error: Need Help
I got Handbrake because I had a problem burning on my DVD-R/Ws. And when I started it, for TV episodes, it worked out perfectly, but once I got to episode 35//50, it didn't do the widescreen format I wanted, and then at 42/50, it said the the Query Parser encountered an error. And I got this: ...
Music, Pictures & Video


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 16:34.
Twitter Facebook Google+