Results 1 to 4 of 4
  1. #1
    In The Zone Sridhar_Rao's Avatar
    Join Date
    Feb 2007
    Posts
    355

    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.
    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

  2. #2
    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

  3. #3
    हॉर्न ओके प्लीज़ victor_rambo's Avatar
    Join Date
    Sep 2007
    Posts
    1,490

    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.
    विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

    गीक होना माँगता

  4. #4
    In The Zone Sridhar_Rao's Avatar
    Join Date
    Feb 2007
    Posts
    355

    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

Similar Threads

  1. How to insert a code box in MS Word
    By rakz in forum Software Q&A
    Replies: 1
    Last Post: 21-11-2010, 01:53 AM
  2. What is wrong with this php code?
    By Sridhar_Rao in forum Programming
    Replies: 9
    Last Post: 29-01-2009, 04:18 PM
  3. Whats wrong with this C++ code?
    By zegulas in forum Programming
    Replies: 3
    Last Post: 06-03-2008, 07:17 PM
  4. how to insert ep 630 into ear..??
    By nix in forum QnA (read only)
    Replies: 1
    Last Post: 17-01-2008, 11:35 PM
  5. lock code..not security code
    By magneticme200 in forum Mobiles and Tablets
    Replies: 3
    Last Post: 29-12-2007, 07:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Close