Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 04-12-2008, 11:42 PM   #1 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default 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:

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>');
    } 
I have enabled error reporting using error_reporting(E_ALL);
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:
PHP Code:
echo('<p align="Center">There was an error in registering your poll response.'.mysql_error().'</p>'); 
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.
__________________
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

Last edited by Sridhar_Rao; 05-12-2008 at 06:51 PM.
Sridhar_Rao is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 05-12-2008, 01:56 PM   #2 (permalink)
spice it up
 
kapsicum's Avatar
 
Join Date: Apr 2004
Location: mumbai
Posts: 106
Default 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
kapsicum is offline  
Old 05-12-2008, 03:01 PM   #3 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Unable to insert record (what's wrong with php code)

PHP Code:
VALUES('$a16','$a1','$a2',......,'$a15'
Unless the values are an integer, you should put them in quotes.
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 05-12-2008, 06:49 PM   #4 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default 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
Sridhar_Rao is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable INSERT key naveen_reloaded QnA (read only) 14 17-03-2008 12:20 PM
Whats wrong with this C++ code? zegulas Programming 3 06-03-2008 07:17 PM
how to insert ep 630 into ear..?? nix QnA (read only) 1 17-01-2008 11:35 PM
lock code..not security code magneticme200 Mobiles and Tablets 3 29-12-2007 07:15 PM
cant able to Insert automatically Binay 007 Hardware Q&A 3 27-04-2007 04:45 PM

 
Latest Threads
- by gforz
- by soumya
- by Sujeet
- by icebags
- by Charan

Advertisement




All times are GMT +5.5. The time now is 03:02 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2