Jump to content

Recommended Posts

I wanted to run the following piece of code to query the database and pull out the relevant information when the variable choice was set to a specific choice eg.

<?php prop_size('Studio'); ?>

When i run the code it brings up an error and wont return the information, I know the variable is being passed into the function as it will echo out the variable, what am I missing?

This is my first attempt at functions so I am guessing its going to be something either very simple or very obvious any help on this would be appreciated.

The code in the function is below.


function prop_size($choice) {
$sql = "SELECT prop_id, prop_name FROM properties 
		WHERE resort_id='$resort_id' And prop_active='1' And prop_deleted='0' And category='$choice' ORDER BY prop_name";

$result = mysql_query($sql);

	while ($row = mysql_fetch_array($result))
		{
		$prop_id = $row['prop_id'];
		$prop_name = $row['prop_name'];
		echo "<a href='property.php?propid=$prop_id'>$prop_name</a><br/>" ;
	}
}

When i run the code it brings up an error and wont return the information,

 

What does the error say?

 

resort_id='$resort_id'

 

Where does $resort_id come from?

 

Change this line to:

 

   $result = mysql_query($sql) or die(mysql_error());

 

run the code again and tell me if any errors appear and EXACTLY what they say.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.