I have attached a url with a zip file containing some php code which picks up random links feom my directory table, my articles table (another script), and my online bible (another script). But it displays many errors.Homepage: IBelieve Christian Ministries
As you will see in my attachment index.php the first include dir.inc.php written for esyndicat displays properly as seen in: http://www.ibelieve.uni.cc/random/index.php
But there is also a lot of errors I can't figure out why.
Please Help.
Attachement with code: Randomlinks.zip
Randomization code Help
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
You'd be better off just posting your code.
By the errors, I can guess that you're MySQL queries are returning < 2 records. You're trying to show row 1? That's the second returned row. If you think your queries will return one row, access row 0.
Try this on all your queries better debugging:
By the errors, I can guess that you're MySQL queries are returning < 2 records. You're trying to show row 1? That's the second returned row. If you think your queries will return one row, access row 0.
Try this on all your queries better debugging:
Code: Select all
mysql_query($query) or die('Cound not execute query: '.$query.'<br /><strong>'.mysql_error().'</strong>');feyd | Please use
dir.inc.php
art.inc.php
bib.php
Thanks for your interest
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK
[b]index.php[/b]Code: Select all
<?
require 'dir.inc.php';
require 'bib.inc.php';
require 'art.inc.php';
?>Code: Select all
<?
$host="#my_host#";
$username="#my_user#";
$password="#my_pass#";
$database="#my_database#";
$query="SELECT * FROM dir_links ORDER BY RAND() LIMIT 1";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result=mysql_query($query);
$num=mysql_numrows($result);
$url=mysql_result($result,$i,"url");
$title=mysql_result($result,$i,"title");
$description=mysql_result($result,$i,"description");
$i=0;
while ($i < $num)
{
echo "<b>Our Random Url for you:</b><a href=\"$url\">$title</a><br>Description:<br>$description";
$i++;
}
mysql_close();
?>Code: Select all
<?
$host="#my_host#";
$username="#my_user#";
$password="#my_pass#";
$database="#my_database#";
$query="SELECT * FROM ams_articles ORDER BY RAND() LIMIT 1";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result=mysql_query($query);
$num=mysql_numrows($result);
$title=mysql_result($result,$i,"article_title");
$url=mysql_result($result,$i,"article_urltitle");
$catid=mysql_result($result,$i,"article_categoryid");
$query2="SELECT * FROM ams_categories WHERE category_id='$catid' ORDER BY RAND() LIMIT 1";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);
$catname=mysql_result($result2,$i,"category_urltitle");
$i=0;
while ($i < $num)
{
echo "<b>Link:</b><a href=\"http://jimgeo.freehostia.com/article/$catname/$url.html\">$title</a>";
$i++;
}
mysql_close();
?>Code: Select all
<?
$host="#my_host#";
$username="#my_user#";
$password="#my_pass#";
$database="#my_database#";
$query="SELECT * FROM bible_verses ORDER BY RAND() LIMIT 1";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result=mysql_query($query);
$num=mysql_numrows($result);
$booknum=mysql_result($result,$i,"b");
$chapter=mysql_result($result,$i,"c");
$verse=mysql_result($result,$i,"v");
$query2="SELECT * FROM bible_books WHERE id='$booknum' ORDER BY RAND() LIMIT 1";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);
$book=mysql_result($result2,$i,"name");
$i=0;
while ($i < $num)
{
echo "<b>Link:</b><a href=\"http://www.ibelieve.uni.cc/bible/index.php?q=$book%2B$chapter.$verse\">$book $chapter : $verse</a>";
$i++;
}
mysql_close();
?>Thanks for your interest
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England