Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    using combo box to insert data to database

    here is the code i have but its not working?


    i have 3 combo box i want their selected values to be inserted into database


    PHP CODE:
    <?php


    if(isset($_POST['submit']))
    {
    $a = $_POST['Karachi'];

    $b = $_POST['Sukkur'];

    $c = $_POST['ac'];

    $d = $_POST['nonac'];

    $e = $_POST['550'];


    mysql_connect("localhost", "root", "password") or die ('Error'.mysqlerror());

    mysql_select_db("online_bus_project");


    $query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c','$e')";



    mysql_query($query) or die ('Error Cannnot Insert Records!');

    }

    ?>



    HTML CODE:

    <div id="status"><form name="status" method="post" action="bookinginfo.php">
    <br>
    <br>
    <br>
    <table class="note" width="90%" align="center" border="0" cellpadding="2" cellspacing="2">
    <tbody><tr>
    <td colspan="4" class="header" width="100%" align="center"><font size="4" color="royalblue" face="Verdana, Arial, Helvetica, sans-serif"><b class="heading"><span class="header"><font color="#336699">Welcome
    To Online B<span class="heading"><span class="heading">us Reservation</span></span></font></span><br>
    </b><font size="2" color="#ff0000">Please Select your date of departure and destination to proceed ahead with the booking.</font><font size="2" color="#000000">
    </font></font></td>
    </tr>
    <tr>
    <td colspan="4" width="100%">&nbsp;</td>
    </tr>



    <tr>


    <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30">
    <center>

    <br /><center> <strong>From:</strong>
    *****<select id="from">

    <option value = "from1">Karachi</option>

    <option value = "from2">Sukkur</option>

    </select>
    <center><br />
    <strong>To:</strong>**********
    <select id="to"></center>

    <option value = "to1">Sukkur</option>

    <option value = "to2">Karachi</option>
    </select>

    <center><br /><strong>Couch:***</strong>
    <select id="couch"></center>

    <option value = "couch1">NonAC</option>

    <option value = "couch2">AC</option>
    </select>

    </select>



    <!--
    <tr>
    <td width="100%" colspan=4>&nbsp;</td>
    </tr>
    -->
    <tr>
    <td colspan="4" width="100%"><hr width="95%" align="left" noshade="noshade"></td>
    </tr>


    <tr>
    <td colspan="4" width="100%" align="center">


    <input type="submit" value="Submit" />
    </form>
    </td>
    </tr>

    <tr>
    <td colspan="4" align="center">&nbsp;</td>
    </tr>

    <!--
    <tr>
    <td width="100%" align="center" colspan="4">
    <div align="left" class="note">
    <hr noshade width="95%" align="left">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font color="#000000"><br>
    Note :</font></font> <span class="note">Please fill in your departure
    and destination stations, number of seats required and the prefered
    date of your journey in this page and click on "Check Status" </span></div>
    </td>
    </tr>
    -->

    </tbody></table>

    </form></td>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    <input type="submit" value="Submit" />
    You're going to need a name for that submit button in order for it to work with an isset($_POST['submit']);
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    he's also gonna need to collect the var's he's actually posting.

    for instance, to get the value of
    Code:
    <select id="from">
    , use
    PHP Code:
    $a $_POST['from']; 
    instead of
    PHP Code:
    $a $_POST['Karachi']; 

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by ohgod View Post
    he's also gonna need to collect the var's he's actually posting.

    for instance, to get the value of
    Code:
    <select id="from">
    , use
    PHP Code:
    $a $_POST['from']; 
    instead of
    PHP Code:
    $a $_POST['Karachi']; 
    Yes he is, good call.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    changed it all


    now it says

    Parse error: parse error in C:\wamp\www\site\bookinginfo.php on line 103


    which is this:-



    <div id="nav">
    <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','760','height','30','src','images/nav_bar2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/nav_bar2' ); //end AC code
    </script>
    <noscript>

    This line Is 103 <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="760" height="30">
    <param name="movie" value="images/nav_bar2.swf" />
    <param name="quality" value="high" />
    <embed src="images/nav_bar2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="30"></embed>
    </object>
    </noscript>
    </div>

  • #6
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    and it is a swf flash file navigation bar

  • #7
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    im also not understanding this can any one explain


    that with this code the 3 combo boxes are going to work so how? if a user select in one sukkur in other karachi and couch AC then wht is going to happen?

    it will insert these values to database?

    with this code:-

    <?php


    if(isset($_POST['submit']))
    {
    $a = $_POST['from'];

    $b = $_POST['Sukkur'];

    $c = $_POST['ac'];

    $d = $_POST['nonac'];

    $e = $_POST['550'];


    mysql_connect("localhost", "root", "password") or die ('Error'.mysqlerror());

    mysql_select_db("online_bus_project");


    $query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c','$e')";



    mysql_query($query) or die ('Error Cannnot Insert Records!');

    }

    ?>

  • #8
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    like is said before... you need to fix your $_POST variables. you're calling values instead of the form element.

    also, wrap code in the code tags so we can actually read it.

  • #9
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    done i did every thing as u said. but still its giving the error at line 103?
    and line 103 is the navigation bar swf file?
    which is this:
    line no 7 in this code is the line 103 which is showing error which is this

    Parse error: parse error in C:\wamp\www\site\bookinginfo.php on line 103

    Code:
    <div id="nav">
          <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','760','height','30','src','images/nav_bar2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/nav_bar2' ); //end AC code
        </script>
          <noscript>
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="760" height="30">
            <param name="movie" value="images/nav_bar2.swf" />
            <param name="quality" value="high" />
            <embed src="images/nav_bar2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="30"></embed>
          </object>
          </noscript>
        </div>



    also i have done this as u said

    PHP CODE


    Code:
    <?php
    
    
    if(isset($_POST['submit']))
    {
    $a = $_POST['from'];
    
    $b = $_POST['to'];
    
    $c = $_POST['couch'];
    
    $d = $_POST['550'];
    
    
    
    mysql_connect("localhost", "root", "password") or die ('Error'.mysqlerror());
    
    mysql_select_db("online_bus_project");
    
     
    $query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c')";
    
     
    
    mysql_query($query) or die ('Error Cannnot Insert Records!');
    
    }
    
    ?>

    HTML CODE


    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>Untitled Document</title>
    <link href="obrs.css" rel="stylesheet" type="text/css" />
    <!--[if IE 5]>
    <style type="text/css"> 
    /* place css box model fixes for IE 5* in this conditional comment */
    .twoColFixRtHdr #sidebar1 { width: 220px; }
    </style>
    <![endif]--><!--[if IE]>
    <style type="text/css"> 
    /* place css fixes for all versions of IE in this conditional comment */
    .twoColFixRtHdr #sidebar1 { padding-top: 30px; }
    .twoColFixRtHdr #mainContent { zoom: 1; }
    /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
    </style>
    <![endif]-->
    <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    <style type="text/css">
    <!--
    .style1 {
    	color: #FFFF00;
    	font-weight: bold;
    }
    .style2 {
    	color: #FFFF66;
    	font-weight: bold;
    }
    #apDiv1 {
    	position:absolute;
    	left:35px;
    	top:168px;
    	width:621px;
    	height:362px;
    	z-index:1;
    }
    -->
    </style>
    
    
    </head>
    
    <body class="twoColFixRtHdr">
    <div id="container">
      <div id="header">
        <!-- end #header -->
        <img src="images/header" alt="OBTRS: Header" /></div>
      <div id="sidebar1">
        <!-- end #sidebar1 -->
        <img src="images/sidebar_slideshow" alt="" />
        <div id="blogarea">
          <p class="style2">Casual Dining Restaurants</p>
          <p><br />
            Our family-style restaurants are the favorite of thousands of tourists and professional drivers alike. Our clean and friendly surroundings encourage people to stop and enjoy a wholesome meal with us when they travel. Our customers recognize our strong teamwork ethic as we provide them quality service.</p>
          <p><br />
              <span class="style1">Convenience Stores</span></p>
          <p><br />
            Our cashiers take pride in having the items on the shelf ready for our travelers when they stop. We know many are in a hurry and we need to be &quot;fast&quot; to meet their busy schedules. Some of our returning customers enjoy fresh coffee and we have it ready for them. The joint effort of our managers and associates creates a strong &quot;team spirit&quot; that provides the customers what they are looking for as they travel.</p>
        </div>
      </div>
      <div id="mainContent">
        <div id="nav">
          <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','760','height','30','src','images/nav_bar2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/nav_bar2' ); //end AC code
        </script>
          <noscript>
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="760" height="30">
            <param name="movie" value="images/nav_bar2.swf"/>
            <param name="quality" value="high" />
            <embed src="images/nav_bar2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="30"></embed>
          </object>
          </noscript>
        </div>
        
        <div id="status"><form name="status" method="post" action="bookinginfo.php">
    			  <br>
      <br>
      <br>
      <table class="note" width="90%" align="center" border="0" cellpadding="2" cellspacing="2">
        <tbody><tr> 
          <td colspan="4" class="header" width="100%" align="center"><font size="4" color="royalblue" face="Verdana, Arial, Helvetica, sans-serif"><b class="heading"><span class="header"><font color="#336699">Welcome 
            To Online B<span class="heading"><span class="heading">us Reservation</span></span></font></span><br>
            </b><font size="2" color="#ff0000">Please Select your date of departure and destination to proceed ahead with the booking.</font><font size="2" color="#000000"> 
            </font></font></td>
        </tr>
        <tr> 
          <td colspan="4" width="100%">&nbsp;</td>
        </tr>
        
      
     
    <tr> 
      
      
      <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30"> 
    <center>
      
       <br /><center> <strong>From:</strong>  	 	 
    	*****<select id="from">
    
    	<option value = "from1">Karachi</option>
    
    	<option value = "from2">Sukkur</option>
    		
    	</select>
    	 <center><br />
    	 <strong>To:</strong>**********
         <select id="to"></center>
    
    	<option value = "to1">Sukkur</option>
    
    	<option value = "to2">Karachi</option>
     </select>
     
         <center><br /><strong>Couch:***</strong>
         <select id="couch"></center>
    
    	<option value = "couch1">NonAC</option>
    
    	<option value = "couch2">AC</option>
     </select>
    	
        </select>
        
        
        
        <!--
        <tr> 
          <td width="100%" colspan=4>&nbsp;</td>
        </tr>
        -->
        <tr> 
          <td colspan="4" width="100%"><hr width="95%" align="left" noshade="noshade"></td>
        </tr>
         
      
       <tr> 
          <td colspan="4" width="100%" align="center"> 
          
    
    	<input type="submit" value="Submit" name="submit"> 
    	</form>
          </td>
        </tr>
      
        <tr> 
          <td colspan="4" align="center">&nbsp;</td>
        </tr>
         
    <!--
        <tr> 
          <td width="100%" align="center" colspan="4"> 
            <div align="left" class="note"> 
              <hr noshade width="95%" align="left">
              <font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font color="#000000"><br>
              Note :</font></font> <span class="note">Please fill in your departure 
              and destination stations, number of seats required and the prefered 
              date of your journey in this page and click on "Check Status" </span></div>
          </td>
        </tr>
        -->
         
      </tbody></table>
    		  
    	</form></td>
    	</tr>
    	</tbody></table></div>
        <div id="features"></div>
        <!-- end #mainContent -->
      </div>
      <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
      <br class="clearfloat" />
      <div id="footer">
        <p><a href="aboutus.html">About us</a> |<a href="feedback.html"> Feedback</a> |<a href="faqs.html"> FAQs</a> | <a href="terms.html">Terms &amp; Conditions</a> | <a href="contactus.html">Contact us</a></p>
        <p> 2009 Copyright - Shah Abdul Latif University Khairpur</p>
        <!-- end #footer -->
      </div>
      <!-- end #container -->
    </div>
    
    </body>
    </html>

  • #10
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    cmon guys every thing looks fine then why this error????

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You need to provide the code for the correct file, the block you're indicating is not php.

    bookinginfo.php appears to be the one with you're $_POST values, given the form action you've provided.
    Anyway, mysqlerror() is not a function. What you want is mysql_error()

    BTW, you won't get what you're expecting from those fields. You need to first and formost name them.
    'from' will contain 'from1' or 'from2'
    'to' will contain 'to1' or 'to2'
    'couch' will contain 'couch1' or 'couch2'

    Chances are you'll want to change the option values for them to correspond to the locations and whatever the couch is.
    Last edited by Fou-Lu; 05-05-2009 at 10:53 PM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #12
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    that's ok i have changed them but what about the error?


    which it shows in this line?
    <param name="movie" value="images/nav_bar2.swf"/>

    if every thing is ok it wont have to give the error.

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Parse error: parse error in C:\wamp\www\site\bookinginfo.php on line 103

    Post the code for bookinginfo.php.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #14
    New Coder
    Join Date
    May 2009
    Location
    Las Vegas
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by m-hrt View Post
    that's ok i have changed them but what about the error?


    which it shows in this line?
    <param name="movie" value="images/nav_bar2.swf"/>

    if every thing is ok it wont have to give the error.
    I usually try everything I can when I get parse error. Try it without the last /

    <param name="movie" value="images/nav_bar2.swf">

  • #15
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    done every thing not working guys.

    but i have another solution

    when ever im trying it with its self action="<?php echo $_SERVER['PHP_SELF']; ?>"

    it gives this error

    Notice: Undefined index: from in C:\wamp\www\site\booking.php on line 6

    Notice: Undefined index: to in C:\wamp\www\site\booking.php on line 8

    Notice: Undefined index: couch in C:\wamp\www\site\booking.php on line 10

    Notice: Undefined index: 550 in C:\wamp\www\site\booking.php on line 12
    Error Cannnot Insert Records!
    if we will be able to solve this may be it sends its sayin undefined index and finally its going to the error

    Code:
    mysql_query($query) or die ('Error Cannnot Insert Records!');

    here is the code is there any solution

    Code:
    <?php
    
    
    if(isset($_POST['submit']))
    {
    $a = $_POST['from'];
    
    $b = $_POST['to'];
    
    $c = $_POST['couch'];
    
    $d = $_POST['550'];
    
    
    
    mysql_connect("localhost", "root", "autodeskmaya") or die ('Error'.mysql_error());
    
    mysql_select_db("online_bus_project");
    
     
    $query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c')";
    
     
    
    mysql_query($query) or die ('Error Cannnot Insert Records!');
    
    }
    
    ?>

    HTML CODE:

    Code:
    <div id="status"><form name="status" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    			  <br>
      <br>
      <br>
      <table class="note" width="90%" align="center" border="0" cellpadding="2" cellspacing="2">
        <tbody><tr> 
          <td colspan="4" class="header" width="100%" align="center"><font size="4" color="royalblue" face="Verdana, Arial, Helvetica, sans-serif"><b class="heading"><span class="header"><font color="#336699">Welcome 
            To Online B<span class="heading"><span class="heading">us Reservation</span></span></font></span><br>
            </b><font size="2" color="#ff0000">Please Select your date of departure and destination to proceed ahead with the booking.</font><font size="2" color="#000000"> 
            </font></font></td>
        </tr>
        <tr> 
          <td colspan="4" width="100%">&nbsp;</td>
        </tr>
        
      
     
    <tr> 
      
      
      <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30"> 
    <center>
      
       <br /><center> <strong>From:</strong>  	 	 
    	*****<select id="from">
    
    	<option value = "karachi">Karachi</option>
    
    	<option value = "sukkur">Sukkur</option>
    		
    	</select>
    	 <center><br />
    	 <strong>To:</strong>**********
         <select id="to"></center>
    
    	<option value = "sukkur">Sukkur</option>
    
    	<option value = "karachi">Karachi</option>
     </select>
     
         <center><br /><strong>Couch:***</strong>
         <select id="couch"></center>
    
    	<option value = "nonac">NonAC</option>
    
    	<option value = "ac">AC</option>
     </select>
    	
        </select>
        
        
        
        <!--
        <tr> 
          <td width="100%" colspan=4>&nbsp;</td>
        </tr>
        -->
        <tr> 
          <td colspan="4" width="100%"><hr width="95%" align="left" noshade="noshade"></td>
        </tr>
         
      
       <tr> 
          <td colspan="4" width="100%" align="center"> 
          
    
    	<input type="submit" value="Submit" name="submit"> 
    	</form>


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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