User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 423,653 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,129 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 1992 | Replies: 1
Reply
Join Date: Feb 2005
Posts: 11
Reputation: supersonic is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
supersonic supersonic is offline Offline
Newbie Poster

database driven link layout

  #1  
Feb 13th, 2005
What I'm attempting is to have database driven links on my page. It is all ok except one thing and that is this error when my page comes up in the browser.


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/admin/public_html/index.php on line 114

Here is my code.

<html> 

<head> 

<style>

.root_td 
{ 

background-color: #000000; 

color: #FFCF00; 

font-family: Verdana; 

font-size: 8pt; 

font-weight: bold; 

height: 22; 

padding-left: 5; 

}

.child_td 

{ 

background-color: #D1D1D1; 

color: #000000; 

font-family: Verdana; 

font-size: 8pt; 

font-weight: bold; 

text-decoration: underline; 

height: 22; 

padding-left: 10; 

padding-right: 10; 

padding-bottom: 3; 

} 


body 

{ 

color: #000000; 

font-family: Verdana; 

font-size: 8pt; 

font-weight: normal; 

} 

a 

{ 

color: #000000; 

}

</style>

<script language="JavaScript">
function ShowLink(linkObject, imgObject) 
{ 

if(linkObject.style.display == '' || linkObject.style.display == 'inline') 
{ 

linkObject.style.display = 'none'; 

imgObject.src = 'plus.gif'; 

} 

else 

{ 

linkObject.style.display = 'inline'; 

imgObject.src = 'minus.gif'; 

} 

}

</script>

</head> 

<body bgcolor="#FFFFFF">

<table width="250" border="0" cellspacing="0" cellpadding="0"> 

<?php 
while($link = mysql_fetch_array($linkResult)) 

{ 

?>

<tr> 

<td class="root_td">
<img id="img_root_<?php echo $counter; ?>" onClick="ShowLink(td_root_<?php echo $counter; ?>, img_root_<?php echo $counter; ?>)" border="0" src="minus.gif" style="cursor:hand">

<?php echo $node[1]; ?>

</td> 

</tr> 

<tr> 

<td id="td_root_<?php echo $counter++; ?>" class="child_td"> 

<table width="100%">

<?php 



$sql = "select * from links where parentId = {$link[0]} order by title asc"; 
@$childResult = mysql_query($sql); 

while($child = mysql_fetch_row($childResult)) 

{ 

?> 

<tr> 

<td class="child_td"> 

<a href="<?php echo $child[2]; ?>"> 

<?php echo $child[1]; ?> 

</a> 

</td> 

</tr>

<?php 

} 

?>

</table> 

</td> 

</tr> 

<?php 

} 

?> 



</table>

</body> 

</html>

Any suggestions? Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: database driven link layout

  #2  
Feb 14th, 2005
you first need to connect to the database first, place the following anywhere before anyof your database queries


$db = mysql_connect("localhost", $user, $pass) or die ("could not establish a database connection");
mysql_select_db($database, $db) or die ("could not access database");


if you will only have 1 active database connection then you could just use the following:
mysql_connect("localhost", $user, $pass) or die ("could not establish a database connection");
mysql_select_db($database) or die ("could not access database");
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 10:46 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC