Jump to content

Problems with form processing to MYSQL database


intenziti

Recommended Posts

I'm wondering if someone would be so kind as to please help me with a problem I am having with a form which upon submitting is to have its data inserted into a MYSQL database.

 

That database and table are set up. The table is called 'reservations' and it has 5 fields to hold the input data. However I keep getting this error:

 

Parse error: syntax error, unexpected $end in /Applications/xampp/xamppfiles/htdocs/paul/reservation_send.php on line 38

 

The funny thing is though that there is no lone 38, the script finishes on line 34. Any ideas on this one? Is the coding I have used the best way to write data to a mysql database or does someone have some better code.

 

I am finding this quite frustrating as you would think it would be an easy enough script to do but I don't seem to be having much luck with it.

 

Any help would greatly be appreciated! Please see below for the code I am using

 

THANK YOU!

 

 

The form code

 

<table width="600" align="center" cellspacing="15"><tr>

<td width="300"> <h3>Please fill out the details below to reserve your place:</h3>

        <br/><form method="post" action="reservation_send.php" ><!--command telling form data to be redirected to php script for processing-->

<table width="100%" border="0" cellspacing="1" cellpadding="2">

  <tr>

<td valign="top" >*</td>

<td colspan="2"><p><strong>Indicates a required field</strong></p>

    </td>

  </tr>

<tr>

<td colspan="3" valign="top"> </td>

  </tr>

  <tr>

<td valign="top" >*</td>

<td class="label">First name:</td>

<td><INPUT TYPE='first name' NAME='first name' SIZE='20'></td><!--Freeform text imput (small area)-->

  </tr>

  <tr>

<td valign="top" >*</td>

<td class="label">Last name:</td>

<td><INPUT TYPE='last name' NAME='last name' SIZE='20'> </td><!--Freeform text imput (small area)-->

  </tr>

  <tr>

<td valign="top" >*</td>

<td class="label">Contact email:</td>

<td><INPUT TYPE='email' NAME='email' SIZE='20'></td>

  </tr>

  <tr>

<td valign="top" ></td>

<td class="label">Contact number(please include country & area codes):</td>

<td><INPUT TYPE='number' NAME='number' SIZE='20'></td>

  </tr>

  <tr>

<td valign="top" >*</td>

<td class="label">Country:</td>

<td><INPUT TYPE='country' NAME='country' SIZE='20'></td>

  </tr>

  <tr>

<td colspan="3" valign="top"> </td>

  </tr>

  <tr>

<td> </td>

<td> </td>

<td><INPUT TYPE="RESET" VALUE="Reset" NAME="reset">

  

<INPUT TYPE="SUBMIT" VALUE="Submit" NAME="submit">

  </td><!--Submit button which user clicks on to send data to php to be processed-->

  </tr>

  </table>

<br>

</form></td></tr></table>

 

 

The PHP script

 

<?php

$dbuser = "sworphe_paul";

$dbserver = "localhost";

$dbpass = "sworphe_paul";

$dbname = "sworphe_paul";

 

//CONNECTION STRING

mysql_connect($dbserver, $dbuser, $dbpass)

or die ("Unable to connect to database");

mysql_select_db($dbname)

or die ("Unable to select database");

 

if ($post == "yes") {

 

$sql = "INSERT INTO reservations (

first name,

last name,

email,

number,

country

$addl_insert_crit ) VALUES ( '$first name',

'$last name',

'$email',

'$number',

'$country'

$addl_insert_values )";

if ($sql_debug_mode==1) { echo "<BR>SQL: $sql<BR>"; }

$result = mysql_query($sql,db());

if ($result == 1) {

echo "Record Inserted";

} else {

echo "Error inserting record (9994SQL)";

}

?>

 

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.