954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Failed to show a form

roomID is used to list all record of some room ID, all the record is associated with roomBookingID. When a user clicked "modify", a form is supposed to show. However, a error message shown after I added the red statement.

<?php require_once('../../config/conn.php');
$roomID=$_GET['roomID'];
$sql="SELECT * FROM roomBooking where roomID = '$roomID'";
$room_query_result=mysql_query($sql,$conn);
$row_rs = mysql_fetch_assoc($room_query_result);
$count=mysql_num_rows($room_query_result);
?>
...

<?php do { ?>

<?php
printf('', $row_rs['roomID']);
printf('', $row_rs['roomBookingID']);
?>

<?php echo $row_rs['bookingDate']; ?>
<?php echo $row_rs['startTime']; ?>
<?php echo $row_rs['endTime']; ?>
<?php echo $row_rs['numberOfPeople']; ?>
<?php printf('modify',$row_rs['roomBookingID']);
?>

<?php } while($row_rs = mysql_fetch_assoc($room_query_result)) ?>




...

<?php
if (isset($_GET['roomID'])) {
$SQL = sprintf("SELECT * FROM roomBooking WHERE roomID = '%s'", $_GET['roomID']);
$rs = mysql_query($SQL, $conn) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
// use heredoc syntax to quote a string and store it in variable $form
$form = <<




房間



日期

(yyyy-mm-dd)



開始時間
(hh-mm-ss)



結束時間
(hh-mm-ss)



使用房間的人數





EOD;
// Substitute a string value into %s found in $form
printf($form,
$row_rs['roomID'],
$row_rs['bookingDate'],
$row_rs['startTime'],
($row_rs['endTime']),
($row_rs['numberOfPeople'])
);
} // end-if
?>

Attachments error.JPG 27.34KB
21122012
Newbie Poster
12 posts since Jan 2012
Reputation Points: 9
Solved Threads: 0
 

use [ code ] tags

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 
<?php require_once('../../config/conn.php');
$roomID=$_GET['roomID'];
$sql="SELECT * FROM roomBooking where roomID = '$roomID'";
$room_query_result=mysql_query($sql,$conn);
$row_rs = mysql_fetch_assoc($room_query_result);
$count=mysql_num_rows($room_query_result);
?>
...
<form method="post" action="del_room.php">
<table border="1">

<?php do { ?>
<tr>
<td>
<?php
printf('<input type="checkbox" name="roomID[]" value="%s" />', $row_rs['roomID']);
....
?>


The error say there is no $row_rs['roomID'] (last line)
this can be because your query returnd FALSE

change
[CODE$room_query_result=mysql_query($sql,$conn);][/CODE]
to

$room_query_result=mysql_query($sql,$conn) or die(mysql_error());
pzuurveen
Posting Whiz in Training
229 posts since Sep 2006
Reputation Points: 32
Solved Threads: 47
 
use [ code ] tags

definitely agree with ardav,! please use[CODE] tags so that we can spot the error(even though you mention it) and it's readable, by the way try using

<?php printf('<a href="roomDetail.php?roomBookingID=%s'">modify</a>',$row_rs['roomBookingID']);


i don't know if it's the same with printf in C and C#, mind me if i'm wrong but %s and %s' is not the same right? , well i guess your error is just parse error .. hope this helps cheers :)

cigoL..:)
Newbie Poster
19 posts since Jul 2011
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You