Help - Search - Members - Calendar
Full Version: Undefined Constant
Zymic Webmaster Forums > Zymic Free Web Hosting > Databases & MySQL
nletham
Hi there,

Sorry to be a pain, I realise a similar post has been posted a few times on these forums recently but they don't help my predicament.

I get a "Notice: Use of undefined constant hotelID - assumed 'hotelID' in /www/zxq.net/n/i/c/nickletham/htdocs/first4hotels/master.php on line 2982" message when I try to run my details page from the master.

I was wondering if anyone knows what I am doing wrong?

Here is my code if someone fancies a look...

Master Page:

<?php do { ?>
<tr>
<td><div align="left"><span class="style2"><?php echo $row_master['title']; ?></span></div></td>
<td><div align="left"><span class="style2"><?php echo $row_master['city']; ?></span></div></td>
<td><div align="left"><span class="style2"><?php echo $row_master['location']; ?></span></div></td>
<td><div align="left" class="style2"><a href="detail.php?hotelIDpar=<?php echo $row_master[hotelID]; ?>">more...</a></div></td>
<td><span class="style2"><?php echo $row_master['hotelID']; ?></span></td>
</tr>
<?php } while ($row_master = mysql_fetch_assoc($master)); ?>

And I want to link the writing in red to my details page as follows...

Details Page:

<?php do { ?>
<table width="100%" border="1">
<tr>
<td><div align="center"><span class="style16">Title:</span></div></td>
<td><div align="center"><span class="style16">City:</span></div></td>
<td><div align="center"><span class="style16">Address:</span></div></td>
<td><div align="center" class="style16">Book:</div></td>
</tr>
<tr>
<td><div align="center"><span class="style2"><?php echo $row_detail['title']; ?></span></div></td>
<td><div align="center"><span class="style2"><?php echo $row_detail['city']; ?></span></div></td>
<td><div align="center"><span class="style2"><?php echo $row_detail['address']; ?></span></div></td>
<td><div align="center" class="style2"><a href="detail.php?hotelIDpar=<?php echo $row_master[hotelID]; ?>">book...</a></div></td>
</tr>
<tr>
<td><div align="center" class="style12"><span class="style13">Description:</span></div></td>
<td><div align="center" class="style16">Location:</div></td>
<td><div align="center" class="style16">Image:</div></td>
<td> </td>
</tr>
<tr>
<td><div align="center" class="style2"><?php echo $row_detail['description']; ?></div></td>
<td><div align="center" class="style2"><?php echo $row_detail['location']; ?></div></td>
<td><div align="center" class="style2"><img src="<?php echo $row_detail['image1_hot']; ?>" alt="" name="pic" id="pic" /></div></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<?php } while ($row_detail = mysql_fetch_assoc($detail)); ?><br />


Full code is attached.


If anyone has any suggestions, it would be much appreciated.

Thanks,

Nick
Jacob
I do not see where you have actually defined what hotelID equals. Could you paste the source where this constant is defined?
nletham
Thank you for your reply. That got me thinking and I have now solved the problem.

You were in fact correct, it wasn't defined at all. This was because of missing apostrophe's surrounding hotelID when referring to my recordset.

The correct code for anyone who might also have this problem is below with the changed information in red...

Master Page:

<?php do { ?>
<tr>
<td><div align="left"><span class="style2"><?php echo $row_master['title']; ?></span></div></td>
<td><div align="left"><span class="style2"><?php echo $row_master['city']; ?></span></div></td>
<td><div align="left"><span class="style2"><?php echo $row_master['location']; ?></span></div></td>
<td><div align="left" class="style2"><a href="detail.php?hotelIDpar=<?php echo $row_master['hotelID']; ?>">more...</a></div></td>
<td><span class="style2"><?php echo $row_master['hotelID']; ?></span></td>
</tr>
<?php } while ($row_master = mysql_fetch_assoc($master)); ?>

Thanks again for your help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.