Solved

if i cant find a result in my db..do this

Posted on 2009-04-10
3
163 Views
Last Modified: 2013-12-12
i need to be able to display a message if a users has not posted anything in the forum.... im not sure how to get this right... here is my attempt
<?php $sql = "Select * FROM forumtutorial_posts where author = '$profilename' ORDER BY `showtime` DESC LIMIT 0, 5";
$postsresult = mysql_query($sql) or die("Could not get threads");
while($row = mysql_fetch_assoc($postsresult)) {  echo ' <a id="posts" href="http://www.runningprofiles.com/members/index.php?page=message&forum='.$row['forum'].'&id='.$row['postid'].'&pagenum=last">'.$row['title'].'</a> <br />' ;} [b]if ($postresults < 0)[/b] {echo 'user has yet to make a post.';}?>

Open in new window

0
Comment
Question by:runnerjp
  • 2
3 Comments
 
LVL 28

Expert Comment

by:gamebits
ID: 24115735
<?php $sql = "Select * FROM forumtutorial_posts where author = '$profilename' ORDER BY `showtime` DESC LIMIT 0, 5";
$postsresult = mysql_query($sql) or die("Could not get threads");
$num = mysql_num_rows($postresult);

if($num < 1)
    {echo 'user has yet to make a post.';}else{
while($row = mysql_fetch_assoc($postsresult)) {  echo ' <a id="posts" href="http://www.runningprofiles.com/members/index.php?page=message&forum='.$row['forum'].'&id='.$row['postid'].'&pagenum=last">'.$row['title'].'</a> <br />' ;}
     }
?>
0
 

Author Comment

by:runnerjp
ID: 24115823
i get Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource  hen it shows  user has yet to make a post. even though i have made sevral
0
 
LVL 28

Accepted Solution

by:
gamebits earned 500 total points
ID: 24115841
Ok I have a typo, replace

$num = mysql_num_rows($postresult);

by

$num = mysql_num_rows($postsresult);
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question