By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

Nested MySQL database call does not return any data

P: n/a
Hi,

I am having a little problem with my PHP - MySQl code, I have two tables
(shown below) and I am trying populate a template page with data from both.
<disclaimer>Now I would like to say my skills, especially with MySQL are
rudimentary</disclaimer> However my code (link below) fails, the nested
database call does not return any data and this has me stumped. Any help
will be much appreciated.

Many thanks in advance

Simon

http://www.charterflights.co.uk/testcode/code.txt

CREATE TABLE `DESTINATION` (
`ID` int(11) NOT NULL auto_increment,
`AREA_ID` int(11) NOT NULL default '0',
`IATA_CODE` char(3) NOT NULL default '',
`DESTINATION_NAME` varchar(30) NOT NULL default '',
`GRAPHIC` varchar(30) NOT NULL default '',
`DESCRIPTION` text NOT NULL,
`CONTENT_DESC` text NOT NULL,
`KEYWORDS` text NOT NULL,
UNIQUE KEY `DESTINATION_NAME` (`DESTINATION_NAME`),
KEY `ID` (`ID`)
) TYPE=MyISAM AUTO_INCREMENT=17 ;

#
# Dumping data for table `DESTINATION`
#

INSERT INTO `DESTINATION` VALUES (7, 3, 'TFS', 'Tenerife', '', 'The largest
of the Canary Islands has two distinct climates. The south is desert like,
hot and dry, while the north is altogether more lush and tropical, tending
to be cooler and wetter. Tenerife is home to Mount Teide, a giant snow
capped volcano and Spain\'s highest peak. Tenerife started of as winter sun
destination but it is now popular year round and offers many modern well
equipped purpose built resorts and complexes. Tenerife really does have
something for everyone, Las Americas with it\'s strip of bars and clubs and
intense nightlife to specialist golf club resorts and the old colonial charm
of Santa Cruz in the North.', '', '');
INSERT INTO `DESTINATION` VALUES (11, 3, 'FUE', 'Fuerteventura', '', 'The
second largest Canary Island but the least populated is a beach lovers
dream, offering over 150 separate beaches to choose from. The scenery is
dominated by the island\'s volcanic history and has a bizarre beauty.
Fuerteventura (big wind) is a popular destination for sailors and especially
windsurfers who hold several competitions through out the year. The
atmosphere on the Island is that of peace and quiet and the nightlife is a
lot quieter than that of Tenerife or Gran Canaria.', '', '');
INSERT INTO `DESTINATION` VALUES (12, 3, 'LPA', 'Gran Canaria', '', 'The
capital Las Palmas boasts historic museums, galleries and shops giving it a
very cosmopolitan feel. The Island offers a variety of landscapes unexpected
in a small island, the north is dominated by pine forest and plantations,
the centre is a rugged collection of ravines and cliffs and the south has
long sandy beaches backed by huge sand dunes. After a hard day on one of
Gran Canaria great beaches there plenty of restaurants, bars and clubs to
party the night away in.', '', '');
INSERT INTO `DESTINATION` VALUES (13, 3, 'SPC', 'La Palma', '', 'World
famous for its huge volcanic crater and often referred to as the \'Green
Island\' La Palma is a rocky mountainous island surrounded by cliffs. The
resorts here a small and peaceful with relaxed and friendly atmospheres.
There are a few coves with small beaches of pebbles or black volcanic
sand.', '', '');
INSERT INTO `DESTINATION` VALUES (14, 3, 'ACE', 'Lanzarote', '', 'The
weather systems travelling from the near by Sahara ensures long sunny days
in Lanzarote. The scenery is almost lunar and at \'fire mountain\' you can
see the hissing volcanic activity for yourself. Most resorts are on the
quiet side and cater well for beach and water sports enthusiasts.', '', '');

CREATE TABLE `RESORT` (
`ID` int(11) NOT NULL auto_increment,
`DEST_ID` int(11) NOT NULL default '0',
`RESORT_NAME` varchar(30) NOT NULL default '',
`GRAPHIC` varchar(30) NOT NULL default '',
`DESCRIPTION` text NOT NULL,
KEY `ID` (`ID`)
) TYPE=MyISAM AUTO_INCREMENT=24 ;

#
# Dumping data for table `RESORT`
#

INSERT INTO `RESORT` VALUES (1, 7, 'Playa Las Americas', '', ' Tenerife\'s
\'most popular resort\' has several beaches, some white sand and some black
and stretches along the coast as far as Los Christianos. The promenade is
lined by shops and restaurants, Las Americas comes alive at night with
Casinos, bars and clubs.\r\nCharter flights from the UK to Tenerife flying
time 4 hours. Airport transfer 30 minutes.');
INSERT INTO `RESORT` VALUES (2, 7, 'Play Paraiso', '', 'Is a small quiet
resort to the north of Las Americas, it is set in a cove with a pebble beach
and a lagoon-style Lido. The are a few restaurants and bars. Transfer time
from Tenerife south airport 1 hour.');
INSERT INTO `RESORT` VALUES (3, 7, 'Playa de la Areina', '', 'Close to the
spectacular cliffs of Los Gigantes with a gently sloping black sand beach
Playa de la AReina offers a selection of bars and restaurants If you fancy a
change of pace then there is a regular bus service into Las americas taking
about 30 minutes. Transfer from Reina Sofia airport takes 1 hour and 45
minutes.');
INSERT INTO `RESORT` VALUES (4, 7, 'Peurto de Santiago', '', 'Set on the
west coast of the island the coast here is suited to walkers, there are
sweeping valleys and small coves to explore. The resort its self offers a
wide selection of shops, bars and restaurants, enough to cater to most
tastes. Transfer time is 1 hour and 45 minutes.');
INSERT INTO `RESORT` VALUES (5, 7, 'Peurto de la Cruz', '', 'The islands
oldest resort and still very popular with Spanish visitors offers a massive
array of shops, bars and restaurants set amongst the towns squares. The Old
town retains much of its Canarian charm. Peurto de la Cruz also offers a
beach front lido and a man made white sand beach at Punta Brava as well as
original stretches of black sand beaches.\r\nCharters operate UK to Tenerife
south Reina Sofia , Transfer 1 hour 40 minutes. (Although Tenerife North
airport is closer it is only served by scheduled flights from the UK via
Madrid or Barcelona )');
INSERT INTO `RESORT` VALUES (6, 7, 'La Caleta', '', 'This resort is just
outside Las Americas and offers a hand full of bars and a few restaurants as
well as a mini market. There are several black sand beaches to chose from.
Transfer 50 minutes from Reina Sofia airport.');
INSERT INTO `RESORT` VALUES (7, 7, 'Los Christianos', '', 'Now very much a
twin resort with Las Americas, Los Christianos retains a lot of its original
fishing village style. The town centre is a pedestrian zone and there are
many small streets leading off from the town square along which there are
numerous shops and restaurants The town beach is original black sand but the
stretch of beach towards Las Americas boasts a wide sweep of white sand
imported from the Sahara. Night life is quite quiet but the main strip of
Playa de las Americas is only a few minutes taxi ride away. Transfer 25
minutes.');
INSERT INTO `RESORT` VALUES (8, 7, 'Golf de Sur', '', 'As the name suggest
this a custom built golfing resort catered for those looking for a warm golf
holiday year round. Much of the accommodation is time share although some is
available for rental to holiday makers. There are a few bars and
restaurants, and the resort is mid way between the airport and Los
Christianos Transfer 15 minutes.');
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Simon dsl.pipex.com>" <simon.perry<AT> wrote in message
news:3f**********************@news.dial.pipex.com. ..
Hi,

I am having a little problem with my PHP - MySQl code, I have two tables
(shown below) and I am trying populate a template page with data from both. <disclaimer>Now I would like to say my skills, especially with MySQL are
rudimentary</disclaimer> However my code (link below) fails, the nested
database call does not return any data and this has me stumped. Any help
will be much appreciated.

Many thanks in advance

Simon

http://www.charterflights.co.uk/testcode/code.txt

CREATE TABLE `DESTINATION` (
`ID` int(11) NOT NULL auto_increment,
`AREA_ID` int(11) NOT NULL default '0',
`IATA_CODE` char(3) NOT NULL default '',
`DESTINATION_NAME` varchar(30) NOT NULL default '',
`GRAPHIC` varchar(30) NOT NULL default '',
`DESCRIPTION` text NOT NULL,
`CONTENT_DESC` text NOT NULL,
`KEYWORDS` text NOT NULL,
UNIQUE KEY `DESTINATION_NAME` (`DESTINATION_NAME`),
KEY `ID` (`ID`)
) TYPE=MyISAM AUTO_INCREMENT=17 ;

#
# Dumping data for table `DESTINATION`
#

INSERT INTO `DESTINATION` VALUES (7, 3, 'TFS', 'Tenerife', '', 'The largest of the Canary Islands has two distinct climates. The south is desert like,
hot and dry, while the north is altogether more lush and tropical, tending
to be cooler and wetter. Tenerife is home to Mount Teide, a giant snow
capped volcano and Spain\'s highest peak. Tenerife started of as winter sun destination but it is now popular year round and offers many modern well
equipped purpose built resorts and complexes. Tenerife really does have
something for everyone, Las Americas with it\'s strip of bars and clubs and intense nightlife to specialist golf club resorts and the old colonial charm of Santa Cruz in the North.', '', '');
INSERT INTO `DESTINATION` VALUES (11, 3, 'FUE', 'Fuerteventura', '', 'The
second largest Canary Island but the least populated is a beach lovers
dream, offering over 150 separate beaches to choose from. The scenery is
dominated by the island\'s volcanic history and has a bizarre beauty.
Fuerteventura (big wind) is a popular destination for sailors and especially windsurfers who hold several competitions through out the year. The
atmosphere on the Island is that of peace and quiet and the nightlife is a
lot quieter than that of Tenerife or Gran Canaria.', '', '');
INSERT INTO `DESTINATION` VALUES (12, 3, 'LPA', 'Gran Canaria', '', 'The
capital Las Palmas boasts historic museums, galleries and shops giving it a very cosmopolitan feel. The Island offers a variety of landscapes unexpected in a small island, the north is dominated by pine forest and plantations,
the centre is a rugged collection of ravines and cliffs and the south has
long sandy beaches backed by huge sand dunes. After a hard day on one of
Gran Canaria great beaches there plenty of restaurants, bars and clubs to
party the night away in.', '', '');
INSERT INTO `DESTINATION` VALUES (13, 3, 'SPC', 'La Palma', '', 'World
famous for its huge volcanic crater and often referred to as the \'Green
Island\' La Palma is a rocky mountainous island surrounded by cliffs. The
resorts here a small and peaceful with relaxed and friendly atmospheres.
There are a few coves with small beaches of pebbles or black volcanic
sand.', '', '');
INSERT INTO `DESTINATION` VALUES (14, 3, 'ACE', 'Lanzarote', '', 'The
weather systems travelling from the near by Sahara ensures long sunny days
in Lanzarote. The scenery is almost lunar and at \'fire mountain\' you can
see the hissing volcanic activity for yourself. Most resorts are on the
quiet side and cater well for beach and water sports enthusiasts.', '', '');
CREATE TABLE `RESORT` (
`ID` int(11) NOT NULL auto_increment,
`DEST_ID` int(11) NOT NULL default '0',
`RESORT_NAME` varchar(30) NOT NULL default '',
`GRAPHIC` varchar(30) NOT NULL default '',
`DESCRIPTION` text NOT NULL,
KEY `ID` (`ID`)
) TYPE=MyISAM AUTO_INCREMENT=24 ;

#
# Dumping data for table `RESORT`
#

INSERT INTO `RESORT` VALUES (1, 7, 'Playa Las Americas', '', ' Tenerife\'s
\'most popular resort\' has several beaches, some white sand and some black and stretches along the coast as far as Los Christianos. The promenade is
lined by shops and restaurants, Las Americas comes alive at night with
Casinos, bars and clubs.\r\nCharter flights from the UK to Tenerife flying
time 4 hours. Airport transfer 30 minutes.');
INSERT INTO `RESORT` VALUES (2, 7, 'Play Paraiso', '', 'Is a small quiet
resort to the north of Las Americas, it is set in a cove with a pebble beach and a lagoon-style Lido. The are a few restaurants and bars. Transfer time
from Tenerife south airport 1 hour.');
INSERT INTO `RESORT` VALUES (3, 7, 'Playa de la Areina', '', 'Close to the
spectacular cliffs of Los Gigantes with a gently sloping black sand beach
Playa de la AReina offers a selection of bars and restaurants If you fancy a change of pace then there is a regular bus service into Las americas taking about 30 minutes. Transfer from Reina Sofia airport takes 1 hour and 45
minutes.');
INSERT INTO `RESORT` VALUES (4, 7, 'Peurto de Santiago', '', 'Set on the
west coast of the island the coast here is suited to walkers, there are
sweeping valleys and small coves to explore. The resort its self offers a
wide selection of shops, bars and restaurants, enough to cater to most
tastes. Transfer time is 1 hour and 45 minutes.');
INSERT INTO `RESORT` VALUES (5, 7, 'Peurto de la Cruz', '', 'The islands
oldest resort and still very popular with Spanish visitors offers a massive array of shops, bars and restaurants set amongst the towns squares. The Old town retains much of its Canarian charm. Peurto de la Cruz also offers a
beach front lido and a man made white sand beach at Punta Brava as well as
original stretches of black sand beaches.\r\nCharters operate UK to Tenerife south Reina Sofia , Transfer 1 hour 40 minutes. (Although Tenerife North
airport is closer it is only served by scheduled flights from the UK via
Madrid or Barcelona )');
INSERT INTO `RESORT` VALUES (6, 7, 'La Caleta', '', 'This resort is just
outside Las Americas and offers a hand full of bars and a few restaurants as well as a mini market. There are several black sand beaches to chose from.
Transfer 50 minutes from Reina Sofia airport.');
INSERT INTO `RESORT` VALUES (7, 7, 'Los Christianos', '', 'Now very much a
twin resort with Las Americas, Los Christianos retains a lot of its original fishing village style. The town centre is a pedestrian zone and there are
many small streets leading off from the town square along which there are
numerous shops and restaurants The town beach is original black sand but the stretch of beach towards Las Americas boasts a wide sweep of white sand
imported from the Sahara. Night life is quite quiet but the main strip of
Playa de las Americas is only a few minutes taxi ride away. Transfer 25
minutes.');
INSERT INTO `RESORT` VALUES (8, 7, 'Golf de Sur', '', 'As the name suggest
this a custom built golfing resort catered for those looking for a warm golf holiday year round. Much of the accommodation is time share although some is available for rental to holiday makers. There are a few bars and
restaurants, and the resort is mid way between the airport and Los
Christianos Transfer 15 minutes.');

You should raise this post in the MySQL newgroup (I use
mailing.database.mysql) - however I've been picking up mysql these past six
months and might be able to help...

First off... you are inserting in to the database (writing data) so of
course, no data will be dumped (read). You need to perform a SELECT query
to dump/read data from the database...

Have you bought a book to teach you MySQL? How did you come up with the idea
that an INSERT would read your database? You'll have a very long road ahead
of you if you don't start off on the right foot and the last thing you want
to do is give up due to frustration that was easily solved....

Jul 17 '05 #2

P: n/a
You should raise this post in the MySQL newgroup (I use
mailing.database.mysql) - however I've been picking up mysql these past six months and might be able to help...
Thanks I found it after I posted here!
First off... you are inserting in to the database (writing data) so of
course, no data will be dumped (read). You need to perform a SELECT query
to dump/read data from the database...

Have you bought a book to teach you MySQL? How did you come up with the idea that an INSERT would read your database? You'll have a very long road ahead of you if you don't start off on the right foot and the last thing you want to do is give up due to frustration that was easily solved....


I'm clueless but not that clueless the PHP code I referred to is viewable at
the link just above the relevant table dumps that I included only so people
could see the data structures I am working with.

The fix was a simple typo

$resort_list==@mysql_query($sql);

Should have been:

$resort_list=@mysql_query($sql);

I however was fixated on the problem as being the nesting of two queries and
couldn't see the wood for the trees.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.