| | |
database driven link layout
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2005
Posts: 11
Reputation:
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.
MySQL Syntax (Toggle Plain Text)
<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
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:
MySQL Syntax (Toggle Plain Text)
$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 Syntax (Toggle Plain Text)
mysql_connect("localhost", $user, $pass) OR die ("could not establish a database connection"); mysql_select_db($database) OR die ("could not access database");
![]() |
Similar Threads
- Experienced with Database Driven Websites (Web Development Job Offers)
- How to SEO a large database driven site (Search Engine Optimization)
- A Web Based Database Driven Application Form (Existing Scripts)
- database driven login page (ASP.NET)
- Best CMS for database driven site (PHP)
- mod_rewrite Joomla database driven site (*nix Software)
Other Threads in the MySQL Forum
- Previous Thread: fulltext problem
- Next Thread: what to do with this .SQL script?
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api aws bizspark breathalyzer changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





