Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a PHP Expert!

Join 244,301 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 771 people online right now. Registration is fast and FREE... Join Now!




Cannot insert into the database

 
Reply to this topicStart new topic

Cannot insert into the database, using php to connect to an MS Access database

Corena
1 Jan, 2009 - 05:32 AM
Post #1

New D.I.C Head
*

Joined: 30 Dec, 2008
Posts: 4

trying to connect my php file to a ms access database

CODE


<?php
   $db_connect = odbc_connect('AdultRegistration', 'root', ''); //calls for the database to be opened
    
        if(!$db_connect)
            {
                die("Error in obdc_connect");
            }
        else
            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);
    
    if(!$query)
        {
            echo "Error in odbc_exec (no cursor returned)" . $query;
        }
    
    //used to close the database connection
    odbc_close($db_connect);
        
?>

the code on my form page is

[code]
<?php
  
   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
                                </a>  
                                <br />
                                <br />                        
                           </p>
                
                             <!-- 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\">
                                <tr>
                                  <td>                                  
                                        <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>
                                                            </select>
                                                 </h4>
                                                              
                                                <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>    
                                                    
                                                <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>
                                              
                                              <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>
                                                            </select>
                                             </h4>
                                            
                                             <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>
                                                                                                                                        
                                              <h4> Email

User is offlineProfile CardPM
+Quote Post


PsychoCoder
RE: Cannot Insert Into The Database
1 Jan, 2009 - 03:16 PM
Post #2

loves.Coding(this);
Group Icon

Joined: 26 Jul, 2007
Posts: 12,283



Thanked: 372 times
Dream Kudos: 10775
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
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

User is offlineProfile CardPM
+Quote Post

genesis1989
RE: Cannot Insert Into The Database
4 Jan, 2009 - 03:36 PM
Post #3

New D.I.C Head
*

Joined: 30 Dec, 2008
Posts: 16


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 05:43PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month