GET not SET problem
Posted: Mon Jun 18, 2007 11:12 am
I keep getting these problems:
here is the code (Any help will be apperciated):
Although i have set the both variables, i'm kinda of lost in which direction to go, i put the following code to see whether the code is being set and the condition is returning true.....Notice: Undefined index: DateHeld in line 9
Notice: Undefined index: UserName line 10
Code: Select all
[if (empty($DateHeld )) {
echo '$DateHeld is either 0, empty, or not set at all ';
}
if (empty($UserName )) {
echo '$UserName is either 0, empty, or not set at all $UserName';
}/php]Code: Select all
<?PHP include 'opendb.php'; ?>
<?PHP include 'header.php'; ?>
<?php
if(isset($_GET))
{
$DateHeld= $_GET['DateHeld'];
$UserName= $_GET['UserName'];
extract($_GET);
if (empty($DateHeld )) {
echo '$DateHeld is either 0, empty, or not set at all ';
}
if (empty($UserName )) {
echo '$UserName is either 0, empty, or not set at all $UserName';
}
// Evaluates as true because $var is set
if (isset($DateHeld )) {
echo '$DateHeld is set even though it is empty';
}
$daterep = str_replace("/","-",$AvailableFrom);
$datereps = str_replace("/","-",$AvailableTo);
$dat = str_replace("/","-",$DateHeld);
$newdate = date ("d M Y", strtotime ($daterep));
$newdates = date ("d M Y", strtotime ($datereps));
$newheld = date ("d M Y", strtotime ($dat));
$query = mssql_init ("sp_insertClientDetails");
mssql_bind($query, "@Surname", $surname, SQLVARCHAR);
mssql_bind($query, "@UserID", $UserName, SQLVARCHAR);
mssql_bind($query, "@DateHeld", $newheld, SQLVARCHAR);
mssql_bind($query, "@ForeName", $forename, SQLVARCHAR);
mssql_bind($query, "@DateConfirmed", $newheld, SQLVARCHAR);
mssql_bind($query, "RETVAL", &$ClientDetailID, SQLINT2);
if (($result = mssql_execute($query)) === false)
{
die('Could not execute the query, ' . $query );
//echo "$DateHeld, $UserName";
}
$query2 = mssql_init ("sp_HoldRoom");
mssql_bind($query, "@AvailableFrom", $newdate, SQLVARCHAR);
mssql_bind($query, "@AvailableTo", $newdates, SQLVARCHAR);
mssql_bind($query, "@ClientDetailID", $ClientDetailID, SQLINT2);
mssql_bind($query, "@UserName", $UserName, SQLVARCHAR);
mssql_bind($query, "@HotelRoomID", $HotelRoomID, SQLINT2);
if (($results = mssql_execute($query2)) === false)
{
die('Could not execute the query ' . $query2 );
}
?>
<?PHP
$count=mssql_num_rows($results);
if ($count == 0)
{
echo "<p>Sorry, your search returned no results</p><br><input type='button' value='Retry' onClick='history.go(-1)'>";
} else {
$i=0;
while ($i < $count) {
$row=mssql_fetch_array($results);
?>
<form action="" method="get">
<table width="95%" border="0">
<tr>
<td width="19%"></td>
<td width="12%"><strong>Room Type:</strong></td>
<td width="15%"><strong>Available From:</strong></td>
<td width="13%"><strong>Available To:</strong></td>
<td width="6%"><strong>Notes</strong></td>
<td width="37%"> </td>
</tr>
<?php
while ($rows = mssql_fetch_array($results))
{
echo '<tr>';
echo '<td><a href="roomdetails.php?HotelRoomID=' . $rows['HotelRoomID'] . '">More information on hotel room</a></td>';
echo '<td>' . $rows['RoomType' ] . '</td>';
echo '<td>' . $rows['AvailableFrom' ] . '</td>';
echo '<td>' . $rows['AvailableTo' ] . '</td>';
echo '<td>' . $rows['Notes' ] . '</td>';
echo '<td><input type="radio" name="HotelRoomID" value="' . $rows['HotelRoomID'] . '" />Select ' . $rows['RoomType'] .' to update</td>';
echo '</tr>';
}
?>
<tr>
<td colspan="6"><input type="Submit" value="Hold Room"> <INPUT name="button" type="button" onClick="location.href='http://pb-sql/admin.php'" value="Cancel">
</td>
</tr>
</table>
</form>
<?PHP
?>
<?PHP include 'footer.php'; ?><?PHP }} }
?>Code: Select all