重複の可能性:
PHP: 「通知: 未定義の変数」および「通知: 未定義のインデックス」</a>
PHP - 未定義の変数
私は初めてPHPをやっていますが、とても楽しんでいますが、1つのエラーで立ち往生しています
注意: 未定義の変数: C:\xampp\htdocs\cravendale\showconfirm.php の 32 行目の customerid
注意: 未定義の変数: C:\xampp\htdocs\cravendale\showconfirm.php の 43 行目の holidayid
コードshowconfirm.php
<?php
//Capture the customerid from the URL and send to a local variable
$booking = $_GET['customerid'];
//echo out some blurb
echo "<h2>Thank you for your booking</h2>
You may wish to print this page for future reference
<br />
<br />
<h2>Your details</h2>";
//Open up our dataconnection
include 'config.php';
include 'opendb.php';
//Get the booking details from the database
$getbooking = mysql_query("SELECT *
FROM tblbookings
WHERE tblbookings.bookingid = @$booking");
while($booking = mysql_fetch_array($getbooking))
{
@$customerid = $booking['customerid'];
$holidayid = $booking['holidayid'];
}
//Get the customer details
$getcustomer = mysql_query("SELECT *
FROM tblcustomers
WHERE tblcustomers.customerid = $customerid");
while($customer = mysql_fetch_array($getcustomer))
{
echo "<p><b>First Name:</b> " . $customer['customerfirstname'] . "<br /><br />
<b>Last Name:</b> " . $customer['customerlastname']. "<br /><br /></p><h2>Your Holiday</h2>";
}
$getholiday = mysql_query("SELECT *
FROM tblholidays
WHERE tblholidays.holidayid= $holidayid");
while($myholidays = mysql_fetch_array($getholiday))
{
//We get the destination name
$chosendestination = $myholidays['destinationid'];
$getchosendestination = mysql_query("SELECT tbldestinations.destinationname
FROM tbldestinations
WHERE tbldestinations.destinationid = $chosendestination" );
while($mydestination = mysql_fetch_array($getchosendestination))
{
echo
"<b>Destination: </b>" . $mydestination['destinationname'];
}
//We get the name of the hotel
$chosenhotel = $myholidays['hotelid'];
$getchosenhotel = mysql_query("SELECT tblhotels.hotelname
FROM tblhotels
WHERE tblhotels.hotelid = $chosenhotel" );
while($myhotel = mysql_fetch_array($getchosenhotel))
{
echo
"<br /><br /><b>Hotel: </b>" . $myhotel['hotelname'];
}
//We get the price
$chosenprice = $myholidays['pricebandid'];
$getchosenprice = mysql_query("SELECT tblpricebands.pricebandcost
FROM tblpricebands
WHERE tblpricebands.pricebandid = $chosenprice" );
while($myprice = mysql_fetch_array($getchosenprice))
{
echo
"<br /><br /><b>Price: </b>£" . $myprice['pricebandcost'];
}
$phpdate3 = strtotime( $myholidays['holidaystartdate'] );
$mysqldate3 = date( 'd-m-Y', $phpdate3 );
echo "
<br /><br /><b>Start date: </b>" . $mysqldate3 ;
}
?>
私はこのエラーについて多くのことを調査しました。私が得ている最も近い手がかりは、$customerid の前に「@」を付けることです$holidayid
。エラーは消えますが、フォームからの情報は読み込まれません。
どんな助けでも大歓迎です。