insert by radiobutton

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

insert by radiobutton

Post by hrubos »

I want to book room by cliking radiobutton. It will be inserted into database.No error but not run :

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, http://www.pspad.com">
  <html>
  <head><title>My website</title></head>
  <body>
<form method = "POST" action = "outputRoom.php">
<table border =1>
<tr>
<td>index</td>
<td>Pokoj</td>
<td>Floor</td>
<td>Budova</td>
<td>Stav pokoje</td>
<td>Po&#269;et l&#367;žek</td>
<td>Cena(korun;za jedno místo)</td>
<td>Rezervace</td>


<?php
require_once ("D:\htdocs\BP\db_connectFun.php");
db_connect();

$id_reservation= $_POST['id_reservation'];
if(!get_magic_quotes_gpc())
 {
 $id_reservation = addslashes($id_reservation);
 
 }
$query="SELECT DISTINCT p.id_numberRoom,p.number_room,p.building,p.floor,p.state_room,
p.id_typeRoom, t.number_beg,t.price
FROM pokoj p,type_room t
WHERE p.id_typeRoom =t.id_typeRoom";

//$query_reser = "insert into reservation " . "(id_reservation) values"
	//		. "('$id_reservation')";
	
$query_reser = "insert into resrevation(id_reservation) values('id_reservation')";
			
$result=mysql_query($query);
$result1=mysql_query($query_reser);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num ) {

$id_numberRoom=mysql_result($result,$i,"id_numberRoom");
$number_room=mysql_result($result,$i,"number_room");
$building=mysql_result($result,$i,"building");
$floor=mysql_result($result,$i,"floor");
$state_room=mysql_result($result,$i,"state_room");
$number_beg=mysql_result($result,$i,"number_beg");
$price=mysql_result($result,$i,"price");
//$id_reservation  = mysql_result($result1,$i,"id_resrevation");
?>
<tr>
<?php
echo "<td>$id_numberRoom</td>" ;
echo "<td>$number_room</td>" ;
echo "<td>$floor</td>";
echo "<td>$building</td>";
echo "<td>$state_room</td>";
echo "<td>$number_beg</td>";
echo "<td>$price</td>";
echo '<td><input type = "radio" name = "id_reservation"  ></td>';

$i++ ;
}
?>
</tr>
<tr>
	<td width="59">&nbsp;</td>
		<td>&nbsp;</td>
		<td><input type="submit" value="Submit" name="submit">
    </form></td>
		<td>&nbsp;</td>
	</tr>



</body>
</html>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: insert by radiobutton

Post by volka »

hrubos wrote:No error
There's no error handling in script.

Code: Select all

<?php
error_reporting(E_ALL); ini_set('display_errors', true);
require_once ("D:\htdocs\BP\db_connectFun.php");

...

$result=mysql_query($query) or die(mysql_error().': '.$query);
$result1=mysql_query($query_reser) or die(mysql_error().': '.$query_reser);

...
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Alternate way to debug mysql query is :

Code: Select all

mysql_query($sql_query) or die(msyql_error());
OR More detail :

Code: Select all

mysql_query($sql_query) or die(mysql_error()." Line ".__LINE__);

Or if you are in linux, you can see the realtime error from log without printing on browser by following linux command :

Code: Select all

# tail -f /var/log/mysql.err
# tail -f /var/log/mysql.log

Happy debugging !

With Best Regards,
Dibyendra
Post Reply