Solved

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

Posted on 2009-04-10
3
159 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP and Soap 3 29
XSS cleaning when using ajax & json encode 5 39
showing numeric numbers 2 11
Insert data into database 2 15
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now