Jump to content

Recommended Posts

OK, so im working on a mini forum board, and i ran into some problems...

 

On my view_topic.php file i want the user to be able to see his post_count... which is simple because all i have to do is do a

mysql_query and a mysql_fetch_array.

, which works fine.

 

However i am getting a warning... "Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\wamp\www\EmporaTech_Site\forum\view_topic.php on line 40"..

 

<?php
$id         = isset($_GET['id']) ? $_GET['id']: '';
$result     = mysql_query("SELECT * FROM forum_question WHERE id='$id'");

while($row = mysql_fetch_array($result))
{
$username = isset($row['username'])  ? $row['username']  : '';
$post_count = mysql_query("SELECT * FROM members WHERE username='$username'");
while($row_1 = mysql_fetch_array($post_count))
{
$post_count = $row_1['post_count'];	
$topic    = isset($row['topic'])     ? $row['topic']     : '';
$detail   = isset($row['detail'])    ? $row['detail']    : '';
$view     = isset($row['view'])      ? $row['view']      : '';
$reply    = isset($row['replies'])   ? $row['replies']   : '';
$date     = isset($row['date_time']) ? $row['date_time'] : '';
?>

 

PS... I have a curly brace for the while statement further down in my script, so that's not the issue.

That error comes from a failed query.  Mysql_query returns false when the query fails.  False, as you may know, is not a mysql result set resource.  That's where the error comes from.

 

If your mysql_query returns false, echo mysql_error().  That will show you why it's failing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.