Results 1 to 4 of 4
-
04-12-2008, 11:42 PM #1
Unable to insert record (what's wrong with php code)
Hi guys, help me troubleshoot this simple problem. I am not able to insert a record into a table. here is the code:
I have enabled error reporting using error_reporting(E_ALL);PHP Code:$sql = "insert into mytable(state,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15) VALUES($a16,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$a10,$a11,$a12,$a13,$a14,$a15)";
if (mysql_query($sql)) {
echo('<p align="Center">Your response has been successfully registered.</p>');
//from here begins coding to analyze and display poll results
} else {
echo('<p align="Center">There was an error in inserting record.</p>');
}
but no error is being displayed except for my own custom error (There was an error in inserting record). How can I get it to display the error code too?
OK, I solved this problem by adding a piece of code:
The value of $a1 is B. The error that is displayed now is Unknown column 'B' in 'field list'. What does this mean? Can you spot the error? I even tried echoing the all the variables $a1 to $a16 and they all get displayed correctly.PHP Code:echo('<p align="Center">There was an error in registering your poll response.'.mysql_error().'</p>');
Last edited by Sridhar_Rao; 05-12-2008 at 06:51 PM.
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
-
05-12-2008, 01:56 PM #2
Re: Unable to insert record (what's wrong with php code)
if possible can u show the error page screenshot of phpmyadmin ... to help u solve it
-
05-12-2008, 03:01 PM #3
Re: Unable to insert record (what's wrong with php code)
Unless the values are an integer, you should put them in quotes.PHP Code:VALUES('$a16','$a1','$a2',......,'$a15')
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति
गीक होना माँगता
-
05-12-2008, 06:49 PM #4
Re: Unable to insert record (what's wrong with php code)
Yes, Rohan is right, I realized that mistake and corrected it. Thanks Rohan for the reply.
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Similar Threads
-
How to insert a code box in MS Word
By rakz in forum Software Q&AReplies: 1Last Post: 21-11-2010, 01:53 AM -
What is wrong with this php code?
By Sridhar_Rao in forum ProgrammingReplies: 9Last Post: 29-01-2009, 04:18 PM -
Whats wrong with this C++ code?
By zegulas in forum ProgrammingReplies: 3Last Post: 06-03-2008, 07:17 PM -
how to insert ep 630 into ear..??
By nix in forum QnA (read only)Replies: 1Last Post: 17-01-2008, 11:35 PM -
lock code..not security code
By magneticme200 in forum Mobiles and TabletsReplies: 3Last Post: 29-12-2007, 07:15 PM



LinkBack URL
About LinkBacks

Bookmarks