Jump to content

Php Form Test w/ MySql Database - Syntax Error


Mythiel

Recommended Posts

Ive made myself a small test form to check to see if i can get connected to my company's new database. However after I submit the form I get this error message:

 

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 11"

 

here is my code

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>PhP Contact Form</title></head><body><?php$errors = '0';if( isset( $_POST['name']) and $errors == 0){    echo '<p>Thank you for your submission!</p>';        $to = '[email protected]';    $subject = 'Contact Form Submission';    $message = 'You have received a contact form submmision:    First Name: '.$_POST['name'].'';        $headers = 'From: Contact Form Alert <[email protected]>'."\n\r";        mail( $to, $subject, $message, $headers );                    $connect = mysql_connect( 'localhost','********', '********' )        or die( mysql_error() );        mysql_select_db( 'softsigns', $connect )        or die( mysql_error() );            $query = 'INSERT INTO test_db (            test_name,            test_value,            test_date                    ) VALUES (            "'.$_POST['name'].'",            "'.$_POST['value'].'",            "'.$_POST['date'].'",                    )';    mysql_query( $query, $connect )        or die( mysql_error() );                }else{    ?>    <form id="contact_form"          name="contact_form"          method="post"          action="PhpFormtest.php">                                                           <table width="636" border="0">          <tr>            <td width="111">                <div align="right">Name:</div>            </td>              <td width="510">                <input type="text"                 name="name"                 value="<?php echo @$_POST['name']; ?>"/>            </td>            <td width="1" rowspan="11"> </td>          </tr>          <tr>            <td width="111">                <div align="right">Value:</div>            </td>              <td width="510">                <input type="text"                 name="value"                 value="<?php echo @$_POST['value']; ?>"/>         </td>            <td width="1" rowspan="11"> </td>          </tr>          <tr>            <td>               <div align="right">Date:</div>            </td>          <td>                <input type="text"                 name="date"                  value="<?php echo @$_POST['date']; ?>"/>            </td>          </tr>          <tr>              <td>                <input type="submit" name="submit" value="submit">                <input type="hidden" name="submitted" id="submitted" value="true" />           </td>            <td colspan="4">                       </td>          </tr>      </table>         </form>        <?php}?></body></html>

 

 

Any Suggestions?

Error in your INSERT query. Please change your INSERT query with below string.

 

 

$query = 'INSERT INTO test_db (            test_name,            test_value,            test_date                    ) VALUES (            "'.$_POST['name'].'",            "'.$_POST['value'].'",            "'.$_POST['date'].'"                    )';

 

 

You add extra comma(,) after $_POST['date'].

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.