•
•
•
•
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
![]() |
•
•
Join Date: Feb 2005
Posts: 11
Reputation:
Rep Power: 0
Solved Threads: 0
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.
Any suggestions? Thanks
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
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation:
Rep Power: 4
Solved Threads: 2
you first need to connect to the database first, place the following anywhere before anyof your database queries
if you will only have 1 active database connection then you could just use the following:
$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");![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- database driven login page (ASP.NET)
- MP3 to Database (ASP.NET)
- Unrecognized external CD-RW. (Apple Hardware)
Other Threads in the MySQL Forum
- Previous Thread: fulltext problem
- Next Thread: what to do with this .SQL script?


Linear Mode