PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
exutable
Forum Newbie
Posts: 5 Joined: Wed Feb 16, 2005 7:35 pm
Post
by exutable » Wed Feb 16, 2005 7:41 pm
Warning: extract(): First argument should be an array in /customers/daneshea.com/daneshea.com/httpd.www/functions.php on line 31
This is what I get from the paging script why doesn't it work?
Code: Select all
if(!$show_from || $show_from < 0) {
$show_from = 0;
}
$pr_page = 20;
$sql = "select ip, id, name, email, message, date_format(time, '%a, %H:%i, %c/%e/%Y') as thetime from tagwall order by time desc limit $show_from, $pr_page";
$result = mysql_query($sql);
$count_amount = "select count(*) as amount from tagwall";
$tag_amountї] = mysql_query($count_amount);
extract($tag_amountї0]);
if($amount > ($show_from + $pr_page)) {
$next_show_from = $show_from + $pr_page;
$next_nav = "<a href="/tagwall.php?show_from=$next_show_from">Next</a>";
}
else {
$next_nav = "<span class="dead-link">Next</span>";
}
if($show_from > 0 && ($show_from - $pr_page) < $amount) {
$prev_show_from = $show_from - $pr_page;
$prev_nav = "<a href="/tagwall.php?show_from=$prev_show_from">Previous</a>";
}
else {
$prev_nav = "<span class="dead-link">Previous</span>";
}
$nav = "<p align="center"><table cellpadding="4">
<tr><td align="center">$prev_nav</td><td align="center">$prev_nav</td></tr>
</p>";
while ($row = mysql_fetch_array($result)) {
extract($row);
?>
<html>
<table cellpadding=2>
<tr><td width=50%>Written By: <? echo "$name"; ?></td></tr>
<tr><td width=50%>Day/Time/Date: <? echo "$thetime"; ?></td></tr>
<tr><td width=50%>Ip: <? echo "$ip"; ?></td></tr>
<tr><td width=50%>Email: <? echo "$email"; ?></td></tr>
<tr><td width=50% height=100 cellpadding=10>Message: <? echo "$message"; ?><br><br><p align=left><span class="class2"><a href="http://www.daneshea.com/<? echo "tagloginconfirm.php?id=$id&action=deleteid"; ?>">Delete</a></span> :: <span class="class2"><a href="http://www.daneshea.com/<? echo "ban.php?deleteid=$id&banip=$ip&name=$name&email=$email"; ?>">Ban</a></span></td></tr></table><br>
</html>
<?
}
echo "$nav";
Last edited by
exutable on Wed Feb 16, 2005 7:54 pm, edited 1 time in total.
Dale
Forum Contributor
Posts: 466 Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks
Post
by Dale » Wed Feb 16, 2005 7:46 pm
Welcome to
DevNetwork ,
Please would you be able to use
tags in your posts from now on please,as it helps us define whats the text and whats the code.
Thank You.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Feb 16, 2005 7:49 pm
try echo'ing out $tag_amount[0] before you extract it. Firstly, it is not an array and you have not fetched the result from that query, you have simply executed it.
Code: Select all
$tag_amountї] = mysql_query($count_amount);
extract($tag_amountї0]);
should be changed to
Code: Select all
$tag_amount = mysql_query($count_amount);
$tag_amount = mysql_fetch_assoc($tag_amount);
echo $tag_amountї'amount'];
Which wil return your count query.
exutable
Forum Newbie
Posts: 5 Joined: Wed Feb 16, 2005 7:35 pm
Post
by exutable » Wed Feb 16, 2005 8:01 pm
Thank you very much it now seems to work.....
exutable
Forum Newbie
Posts: 5 Joined: Wed Feb 16, 2005 7:35 pm
Post
by exutable » Wed Feb 16, 2005 8:40 pm
Here is what it looks like now, but the thing is I have gone over the pr_page of 20 and the next link does not seem to appear as an active link.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Feb 16, 2005 8:48 pm
change instances of $amount.. ie.
Code: Select all
if($amount > ($show_from + $pr_page)) {
to $tag_amount['amount'] ie.
Code: Select all
if($tag_amountї'amount'] > ($show_from + $pr_page)) {
exutable
Forum Newbie
Posts: 5 Joined: Wed Feb 16, 2005 7:35 pm
Post
by exutable » Wed Feb 16, 2005 8:55 pm
Unfortunately the next link comes back to the same exact page instead of go to the next this is EVERYTHING I am using to read the tagwall!
Code: Select all
if(!$show_from || $show_from < 0) {
$show_from = 0;
}
$pr_page = 20;
$result = "select name, email, message, date_format(time, '%a, %H:%i, %c/%e/%Y') as thetime from tagwall order by time desc limit $show_from, $pr_page";
$sql = mysql_query($result);
$count_amount = "select count(*) as amount from tagwall";
$tag_amount = mysql_query($count_amount);
$tag_amount = mysql_fetch_assoc($tag_amount);
if($tag_amountї'amount'] > ($show_from + $pr_page)) {
$next_show_from = $show_from + $pr_page;
$next_nav = "<span class="class2"><a href="/tagwall.php?show_from=$next_show_from">Next</a></span>";
}
else {
$next_nav = "<span class="dead-link">Next</span>";
}
if($show_from > 0 && ($show_from - $pr_page) < $tag_amountї'amount']) {
$prev_show_from = $show_from - $pr_page;
$prev_nav = "<span class="class2"><a href="/tagwall.php?show_from=$prev_show_from">Previous</a></span>";
}
else {
$prev_nav = "<span class="dead-link">Previous</span>";
}
$nav = "<p align="center"><table cellpadding="4">
<tr><td align="center">$prev_nav</td><td align="center">$next_nav</td></tr>
</p>";
while ($row = mysql_fetch_array($sql)) {
extract($row);
echo "<table cellpadding=2>";
echo "<tr><td width=50%>Written By: $name</td></tr>";
echo "<tr><td width=50%>Day/Time/Date: $thetime</td></tr>";
echo "<tr><td width=50%>Email: $email</td></tr>";
echo "<tr><td width=50% height=100 cellpadding=10>Message: $message</td></tr></table><br>";
}
echo "$nav";
}