i have a Listbox available in my page and that Listbox have these items.


and i have trip named table which have these fields.

id which will autocrement
from
to
coach_type
fare
journey_date
seat

now i want this to be happen if a user come and take any item from Listbox it will inserts that that info to these fields not in the seats cuz seat is on the other page.

for example

if a user selects 1st item which is Sukkur-Karachi-(NonAC) then it will insert this data in the field.

in from it insert sukkur
in to it insers karachi
in couchtype it insert nonac
in fare it insert 550

also for the second it insert according to the item in the list box.


after that i have a field which is journey date that is timestamp now i want a calender to be attach to this if user selects date that insers in the journey_date field. please help me out on this.


i have these fields in the listbox.
[IMG][/IMG]

In default situation

[IMG][/IMG]

<?php

$a = $_GET['Karachi'];

$b = $_GET['Sukkur'];

$c = $_GET['ac'];

$d = $_GET['nonac'];

$e = $_GET['550'];

 

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

mysql_select_db("online_bus_project");

 

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

 

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

 

?>


<!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;
}
.style5 {color: #0066FF; font-weight: bold; }
.style6 {
	color: #0066FF;
	font-weight: bold;
	font-size: 24px;
}
.style7 {font-size: 12px}
#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" color="maroon" size="2" width="25%" align="right" height="30">Journey :</td>
  
  <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30"> 

  
      	 	 
	<select id="journey">

	<option value = "Sukkur-Karachi-(NonAC)">Sukkur-Karachi-(NonAC)</option>

	<option value = "Karachi-Sukkur-(NonAC)">Karachi-Sukkur-(NonAC)</option>

	<option value = "Sukkur-Karachi-(AC)">Sukkur-Karachi-(AC)</option>
	
	<option value = "Karachi-Sukkur-(AC)">Karachi-Sukkur-(AC)</option>
	
	<option value = "Karachi-Islamabad-(Volvo)">Karachi-Islamabad-(Volvo)</option>
	</select>
	 
     
      
 </select></td><td font="" face="Verdana, Arial, Helvetica, sans-serif" color="maroon" size="2" width="25%" align="left" height="30">
  </td></tr><tr>

              <td valign="top" align="right">Journey Date:</td>

              </tr>


 
	<!--
    <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" name="submit" value="submit" >
      </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>

Dani AI

Generated

Short, practical checklist to fix this thread's two problems (form values not reaching PHP, and the parse error on line 103).

Your form: selects need name attributes (browsers submit name, not id). Give each select a distinct name (for example origin, destination, coach), and send a separate, server-side mapping from selection -> fare (do not trust a posted numeric value). This is the thing was getting at: read values from $_POST['origin'] etc. rather than trying to use option text parsing. (developer.mozilla.org)

Database and security: stop using the old mysql_* API (it was deprecated and later removed) — move to PDO or mysqli. Use prepared statements (parameterized queries) and bind values instead of building SQL strings with user input; that prevents SQL injection (OWASP). Also make sure the INSERT columns count matches the number of VALUES (BzzBee already pointed out your mismatch). Avoid column names that collide with SQL keywords like from/to — rename to origin/destination or quote them with backticks. Finally, do not connect as root from your web app; create a least-privileged DB user. (wiki.php.net)

Parse error debugging (the message points at the SWF <param> line): that usually means a PHP syntax error occurred earlier in the file (missing semicolon, unclosed quote, unclosed PHP tag), so PHP reached the HTML and failed. Run a syntax check on the file (php -l bookinginfo.php) or use your editor/IDE linter to find the exact line. Check the last PHP block before the HTML and the string that builds the INSERT — unbalanced quotes or concatenation errors are common causes. (geeksforgeeks.org)

Minimal examples you can drop in (adjust names/credentials and server-side fare mapping):

<form method="post" action="bookinginfo.php">
  <select name="origin">
    <option value="Karachi">Karachi</option>
    <option value="Sukkur">Sukkur</option>
  </select>

  <select name="destination">
    <option value="Sukkur">Sukkur</option>
    <option value="Karachi">Karachi</option>
  </select>

  <select name="coach">
    <option value="NonAC">NonAC</option>
    <option value="AC">AC</option>
  </select>

  <input type="date" name="journey_date" />
  <button type="submit" name="submit">Submit</button>
</form>
// use a non-root, limited DB user; compute fare server-side from the selection
$pdo = new PDO('mysql:host=localhost;dbname=online_bus_project;charset=utf8mb4','app_user','secret',[
  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);

$stmt = $pdo->prepare(
  'INSERT INTO trip (origin,destination,coach_type,fare,journey_date) VALUES (:origin,:destination,:coach,:fare,:date)'
);
$stmt->execute([
  ':origin' => $_POST['origin'],
  ':destination' => $_POST['destination'],
  ':coach' => $_POST['coach'],
  ':fare' => $fare,                // map this on the server from the coach+route
  ':date' => $_POST['journey_date'],
]);

For a date picker you can use the native HTML5 date control (input type="date") and still validate on the server. (developer.mozilla.org)

If you run the linter and still see the parse error, post the few lines of PHP immediately above line 103 — the exact syntax issue will be visible there.

Recommended Answers

All 10 Replies

cmon guys i need help????

see line 147 to 148

and the upper php code every thing is ok just tell me how can i put the values for every selection in data base.

A couple of questions..
1. Where are you getting those GET names from? Can't see any reference to them in your code..
2. Why are you putting GET data directly into the database.. That's just asking for trouble. Any and all input from a user should be seen cleaned before database entry.
3. What is so important about line 147/148, I see no problems there.

see this line
You are using four fields but five parameters and some commas are missing.

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

try this now

it should be either c or d (AC or non AC. not both)


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

see this line
You are using four fields but five parameters and some commas are missing.

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

try this now

it should be either c or d (AC or non AC. not both)


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

thanx buddy im goin to check this.


i have a text box and i want a calender to be attach to that i have found a calender dont know how to attach where to put that code can u plz help me out on that two
here is the page which have a calender coding + i want only attach to one text box:-

http://blog.davglass.com/files/yui/cal2/

A couple of questions..
1. Where are you getting those GET names from? Can't see any reference to them in your code..
2. Why are you putting GET data directly into the database.. That's just asking for trouble. Any and all input from a user should be seen cleaned before database entry.
3. What is so important about line 147/148, I see no problems there.

is it ok now??????
i have made 3 combobox one is from other is to and the 3rd is Couch now tell me how can i insert the 3 values of 3 comboboxes to database

my database name is online_bus_project
table name is trip

here is the code i have made some changes check it
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>

Apart from the fact that your HTML is appalling.. as I said earlier, where are you getting the (in this case) POST from?

You appear to be using the values that the fields have, this is incorrect.
You should be using:

$a = $_POST['to'];
    $b = $_POST['from'];
    $c = $_POST['couch'];
    $e = $_POST['550'];

This is not recommended though, the user can modify the data sent to the server through a form, you should look into SQL injection and how to prevent it.

hmmm now i got u. i have to insert values of list box in the $_POST let me try this

still the same error which is from the navigation bar swf file

which is on the line 70 of HTML code

HTML 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>

PHP 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!');

}

?>

it looks fine now

ya but why parse error on this:-

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

Line:-

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.