Page 2 of 3
Posted: Thu Jun 28, 2007 4:01 am
by ghadacr
Ok Thanks for the script,
This is what i'm getting
HotelRoomID: array(2) {
[0]=>
string(2) "24"
[1]=>
string(2) "38"
}
and only "38" is outputting....Hmmmm
Posted: Thu Jun 28, 2007 4:13 am
by volka
But now you didn't get the warning for line 21?
Posted: Thu Jun 28, 2007 4:15 am
by ghadacr
volka wrote:But now you didn't get the warning for line 21?
No....
Posted: Thu Jun 28, 2007 4:16 am
by volka
Did you change anything else?
Posted: Thu Jun 28, 2007 4:28 am
by ghadacr
volka wrote:Did you change anything else?
No, i only get those errors when i edit the URL, apart from that i dont get the errors
This is what the URL prints for the hotel room ID when i dont edit it:
http://pb-sql/roomhold.php?datefrom=19% ... D%5B%5D=24[/b]&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&datefrom=19%2F06%2F2007&dateto=25%2F06%2F2007&
HotelRoomID%5B%5D=38
When i do edit the url I for the first array(string(2) "24") i dont get any errors:
When i edit it for the second array output(string(2) "38", i get this error output,
HotelRoomID: string(2) "38"
Warning: Invalid argument supplied for foreach() in C:\Inetpub\wwwroot\salessys\roomhold.php on line 22
Notice: Undefined variable: count in C: line 42
Posted: Thu Jun 28, 2007 4:31 am
by volka
ghadacr wrote:No, i only get those errors when i edit the URL, apart from that i dont get the errors
You've edited the url in a way that no array is created.
Posted: Thu Jun 28, 2007 4:39 am
by ghadacr
When the Variables are passed into the script without editing the URL this is what i get:
HotelRoomID: array(2) {
[0]=>
string(2) "46"
[1]=>
string(2) "47"
}
and i have just noticed the arrays are not giving indvidual numbers its all "2"'s Hmm what do you think...
Posted: Thu Jun 28, 2007 4:41 am
by volka
ghadacr wrote:and i have just noticed the arrays are not giving indvidual numbers its all "2"'

Do you mean the 2 in
ghadacr wrote:string(2)
?
That only indicates that the string has a length of 2 bytes.
Posted: Thu Jun 28, 2007 4:45 am
by ghadacr
Sorry i now i understand it was my Java programming making me look at the array differently...
What do you think could be the problem...because only one record is being ouputed and that seems to be the greater HotelRoomID record number..
Posted: Thu Jun 28, 2007 4:49 am
by volka
because you first process all elements of $_GET['HotelRoomID'] and then loop through the last mssql result
try
Code: Select all
$reso=mssql_query($query);
$count=mssql_num_rows($result);
echo '<div>Debug: $count=', $count, "</div>\n";
}}
?>
<form method=get name=f1 action='confirmmholdroom.php'>
<?php
$i=0;
echo "<div>Debug: while ($i < $count) { </div>\n";
while ($i < $count) {
$rows=mssql_fetch_array($result);
and take a look at the output.
Posted: Thu Jun 28, 2007 5:01 am
by ghadacr
This is the output result:
Debug: $count=1
Debug: $count=1
Debug: while (0 < 1) {
Posted: Thu Jun 28, 2007 5:10 am
by volka
Yes, and that tells you.... ?
Posted: Thu Jun 28, 2007 5:13 am
by ghadacr
There is only one record being ouputted.....
Posted: Thu Jun 28, 2007 5:33 am
by volka
hm, maybe the output was to subtle. Next try
Code: Select all
$dateto = $_GET['dateto'];
if(isset($_GET['HotelRoomID']))
{
foreach($_GET['HotelRoomID'] as $k=>$k1)
{
echo "<fieldset><legend> foreach($k => $k1) </legend>\n";
$sql="SELECT * FROM HotelRooms WHERE HotelRoomID=$k1";
$ques="SELECT dbo.Hotels.HotelName FROM Hotels INNER JOIN HotelRooms ON dbo.Hotels.HotelID = dbo.HotelRooms.HotelID WHERE HotelRoomID=$k1";
$query="SELECT dbo.RoomAssociations.RoomAssociation FROM RoomAssociations INNER JOIN HotelRooms ON dbo.RoomAssociations.RoomAssociationID = dbo.HotelRooms.RoomAssociationID WHERE HotelRoomID=$k1";
echo "mssql_query($sql) <br />\n
mssql_query($ques) <br />\n
mssql_query($query) <br />\n";
$result=mssql_query($sql);
$res=mssql_query($ques);
$reso=mssql_query($query);
$count=mssql_num_rows($result);
echo 'count=', $count;
echo '</fieldset>';
}
}
?>
<form method=get name=f1 action='confirmmholdroom.php'>
<?php
$i=0;
while ($i < $count) {
echo "while ($i < $count)\n";
$rows=mssql_fetch_array($result);
Posted: Thu Jun 28, 2007 5:46 am
by ghadacr
What i'm starting to see is that $count=mssql_num_rows($result); is identifying each record with a "1" instead of incrementing each record so 1, 2, 3 ect....
foreach(0 => 46) mssql_query(SELECT * FROM HotelRooms WHERE HotelRoomID=46)
mssql_query(SELECT dbo.Hotels.HotelName FROM Hotels INNER JOIN HotelRooms ON dbo.Hotels.HotelID = dbo.HotelRooms.HotelID WHERE HotelRoomID=46)
mssql_query(SELECT dbo.RoomAssociations.RoomAssociation FROM RoomAssociations INNER JOIN HotelRooms ON dbo.RoomAssociations.RoomAssociationID = dbo.HotelRooms.RoomAssociationID WHERE HotelRoomID=46)
count=1
foreach(1 => 47) mssql_query(SELECT * FROM HotelRooms WHERE HotelRoomID=47)
mssql_query(SELECT dbo.Hotels.HotelName FROM Hotels INNER JOIN HotelRooms ON dbo.Hotels.HotelID = dbo.HotelRooms.HotelID WHERE HotelRoomID=47)
mssql_query(SELECT dbo.RoomAssociations.RoomAssociation FROM RoomAssociations INNER JOIN HotelRooms ON dbo.RoomAssociations.RoomAssociationID = dbo.HotelRooms.RoomAssociationID WHERE HotelRoomID=47)
count=1
while (0 < 1)