Cannot insert into the database

using php to connect to an MS Access database

Page 1 of 1

2 Replies - 1462 Views - Last Post: 04 January 2009 - 04:36 PM Rate Topic: -----

#1 Corena  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-December 08

Cannot insert into the database

Posted 01 January 2009 - 06:32 AM

trying to connect my php file to a ms access database


$db_connect = odbc_connect('AdultRegistration', 'root', ''); //calls for the database to be opened

die("Error in obdc_connect");
echo "Successfully connected to the database";

//used to inser information into the database
$query_string = "INSERT INTO Adult Info (First_Name, Last_Name, Gender, Age, Date of Birth, Medical Condition, Email, Preferred Day) values ('$fname', '$lname', '$gender', '$dob', '$medical', '$email')";

$query = odbc_exec ($db_connect, $query_string);

echo "Error in odbc_exec (no cursor returned)" . $query;

//used to close the database connection


the code on my form page is


include ("pageheader.php");

echo "\t\t<title> Adult Registration | Stingrays Learn-to-swim </title>\n";

include ("pagebodyupper.php");
include ("pagebodyleft.php");

echo "<td valign=\"top\" class=\"whitebg\">
<td valign=\"top\">
<!-- Creates icons that permit uses to move forward or backward to different pages -->
<p align=\"right\">
<a href=\"register.php\"><img src=\"../Images/cylarrw.gif\" border=\"0\" />
<br />
Back to Registration Page
<br />
<br />

<!-- Creates the Register header -->
<h2 align=\"center\"> ADULT CLASSES REGISTRATION FORM </h2>

<!-- Paragraph controlling the registration form -->
<p align=\"center\">
<br />

If you are interested in registering for adult classes with Stingrays Learn-to-swim kindly fill out the information below.
<br />

<!-- Creates the MAIN FORMS TABLE -->
<table align=\"center\">
<form name=\"adultregister\" method=\"post\" action=\"connectdb_adult.php\">
<h4> Prefix:
<select name=\"prefix\" size=\"2\">
<option selected=\"selected\"> Mr. </option>
<option> Mrs. </option>
<option> Ms. </option>
<option> Miss </option>

<h4> First Name: <input type=\"text\" name=\"fname\" value=\"\" size=\"30%\" /> </h4>

<h4> Last Name: <input type=\"text\" name=\"lname\" value=\"\" size=\"30%\" /> </h4>

<h4> Gender:
<input type=\"radio\" name=\"gender\" id=\"male\" /> Male
<input type=\"radio\" name=\"gender\" id=\"female\" /> Female

<h4> Age: <input type=\"text\" name=\"age\" value=\"\" size=\"10%\"/> </h4>

<h4> Date of Birth:
<select name=\"dob\" size=\"1\">
<option> 1 </option>
<option> 2 </option>
<option> 3 </option>
<option> 4 </option>
<option> 5 </option>
<option> 6 </option>
<option> 7 </option>
<option> 8 </option>
<option> 9 </option>
<option> 10 </option>
<option> 11 </option>
<option> 12 </option>
<option> 13 </option>
<option> 14 </option>
<option> 15 </option>
<option> 16 </option>
<option> 17 </option>
<option> 18 </option>
<option> 19 </option>
<option> 20 </option>
<option> 21 </option>
<option> 22 </option>
<option> 23 </option>
<option> 24 </option>
<option> 25 </option>
<option> 26 </option>
<option> 27 </option>
<option> 28 </option>
<option> 29 </option>
<option> 30 </option>
<option> 31 </option>
</select> Day

<select name=\"dob\" size=\"1\">
<option> January </option>
<option> February </option>
<option> March </option>
<option> April </option>
<option> May </option>
<option> June </option>
<option> July </option>
<option> August </option>
<option> September </option>
<option> October </option>
<option> November </option>
<option> December </option>
</select> Month

<select name=\"dob\" size=\"1\">
<option> 1990 </option>
<option> 1989 </option>
<option> 1988 </option>
<option> 1987 </option>
<option> 1986 </option>
<option> 1985 </option>
<option> 1984 </option>
<option> 1983 </option>
<option> 1982 </option>
<option> 1981 </option>
<option> 1980 </option>
<option> 1979 </option>
<option> 1978 </option>
<option> 1977 </option>
<option> 1976 </option>
<option> 1975 </option>
<option> 1974 </option>
<option> 1973 </option>
<option> 1972 </option>
<option> 1971 </option>
<option> 1970 </option>
<option> 1969 </option>
<option> 1968 </option>
<option> 1967 </option>
<option> 1966 </option>
<option> 1965 </option>
<option> 1964 </option>
<option> 1963 </option>
<option> 1962 </option>
<option> 1961 </option>
<option> 1960 </option>
<option> 1959 </option>
<option> 1958 </option>
</select> Year

<h4> Medical Condition if any)
<select name=\"medical\" size=\"3\">
<option selected=\"selected\"> Other </option>
<option> Asthma </option>
<option> Diabetes </option>
<option> Cerebal Palsy </option>
<option> Heart Disease </option>
<option> ADD </option>

<h4> Tel:
<input type=\"text\" name=\"workphone\" value=\"\" size=\"10%\" /> Work

<input type=\"text\" name=\"homephone\" value=\"\" size=\"10%\" /> Home

<input type=\"text\" name=\"cellphone\" value=\"\" size=\"10%\" /> Cell

<h4> Email

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot insert into the database

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Cannot insert into the database

Posted 01 January 2009 - 04:16 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:

  • Post the code you're having problems with (DONE)
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

#3 genesis1989  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 16
  • Joined: 30-December 08

Re: Cannot insert into the database

Posted 04 January 2009 - 04:36 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1