Welcome to WebmasterWorld Guest from 54.166.46.226

Forum Moderators: open

Message Too Old, No Replies

Parameterized Misbehaving

One field returning empty where data exists.

   
12:41 pm on May 13, 2013 (gmt 0)

5+ Year Member



I have the following parameterized query. All fields display as they should, save for 'reservationNote'. If I use a standard mysqli_query command, the field shows up as expected. It also shows as expected when I paste the same statement into PHPMyAdmin. So the problem is with my parameterized query, but I don't know where. Any ideas?


if (!($stmt = $mysqli->prepare("SELECT reservations.reservationID AS resid, reservations.reservationModified, reservations.reservationNote AS reservationNote, bookings.bookingID, bookings.propertyID, bookings.guestID, bookings.addressID, bookings.emailID, bookings.phoneID, bookings.bookingDate, bookings.rawData, bookings.bookingPrice, bookings.bookingTaxExempt, bookings.bookingOccupancy, bookings.bookingModified, addresses.addressLine1 AS address, addresses.addressCity AS city, addresses.addressState AS state, addresses.addressZipcode AS zipcode, guests.guestLName AS lastname, guests.guestFName AS firstname, phonenumbers.phoneNumber AS phone, emails.emailAddress AS email, rooms.roomNumber AS roomnumber, rooms.roomName AS roomname, rooms.roomID AS roomid, taxes.taxAmount AS taxrate FROM reservations LEFT JOIN bookings ON bookings.reservationID = reservations.reservationID LEFT JOIN guests ON guests.guestID = bookings.guestID LEFT JOIN addresses ON addresses.addressID = bookings.addressID LEFT JOIN emails ON emails.emailID = bookings.emailID LEFT JOIN phonenumbers ON phonenumbers.phoneID = bookings.phoneID LEFT JOIN rooms ON rooms.roomID = bookings.roomID LEFT JOIN taxes ON taxes.propertyID = rooms.propertyID WHERE reservations.reservationID = ? AND bookings.bookingStatus = 1 ORDER BY bookings.roomID ASC, bookings.bookingDate ASC"))) { echo "FAILED<RESPONSE>Could not prepare the server: (" . $mysqli->errno . ") " . $mysqli->error; die(); }

#STEP THREE:
#bind and execute
if (!$stmt->bind_param("i", $_GET['id'])) { echo "FAILED<RESPONSE>Parameters failed to bind to server: (" . $stmt->errno . ") " . $stmt->error; die(); }
if (!$stmt->execute()) { echo "FAILED<RESPONSE>Server failed to execute: (" . $stmt->errno . ") " . $stmt->error; die(); }

#STEP FOUR:
#bind and store values
if(!$stmt->bind_result($resid, $reservationModified, $reservationNote, $bookingID, $propertyID, $guestID, $addressID, $emailID, $phoneID, $bookingdate, $raw, $price, $taxexempt, $occupancy, $bookingModified, $address, $city, $state, $zipcode, $lastname, $firstname, $phonenumber, $email, $roomnumber, $roomname, $roomid, $taxrate)) { echo "FAILED<RESPONSE>Server failed to bind result: (" . $stmt->errno . ") " . $stmt->error; die(); }

$results = array();
while ($stmt->fetch()) {
$results[] = array('resid'=>$resid, 'reservationModified'=>$reservationModified, 'reservationNote'=>$reservationNote, 'bookingID'=>$bookingID, 'propertyID'=>$propertyID, 'guestID'=>$guestID, 'addressID'=>$addressID, 'emailID'=>$emailID, 'phoneID'=>$phoneID, 'bookingdate'=>$bookingdate, 'raw'=>$raw, 'price'=>$price, 'taxexempt'=>$taxexempt, 'occupancy'=>$occupancy, 'bookingModified'=>$bookingModified, 'address'=>$address, 'city'=>$city, 'state'=>$state, 'zipcode'=>$zipcode, 'lastname'=>$lastname, 'firstname'=>$firstname, 'phone'=>$phonenumber, 'email'=>$email, 'roomnumber'=>$roomnumber, 'roomname'=>$roomname, 'roomid'=>$roomid, 'taxrate'=>$taxrate);
if(!$stmt->bind_result($resid, $reservationModified, $reservationNote, $bookingID, $propertyID, $guestID, $addressID, $emailID, $phoneID, $bookingdate, $raw, $price, $taxexempt, $occupancy, $bookingModified, $address, $city, $state, $zipcode, $lastname, $firstname, $phonenumber, $email, $roomnumber, $roomname, $roomid, $taxrate)) { echo "FAILED<RESPONSE>Server failed to bind result: (" . $stmt->errno . ") " . $stmt->error; die(); }
}