Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-04-10
3
Medium Priority
?
172 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 2000 total points
ID: 24115841
Ok I have a typo, replace

$num = mysql_num_rows($postresult);

by

$num = mysql_num_rows($postsresult);
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…
Suggested Courses

782 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