...

View Full Version : Urgent Help Need Here Please Display Crisis



husnamina
08-23-2006, 08:29 PM
HI ALL
well am trying to display the result from the sql query that joins two tables. I tested the query it works fine in mysql and give me the required row but when i come to display it only the heading is displayed and NO ERROR MESSAGES WHAT SO EVER.



$sql="select topics.topic_title, topics.mod_id as mt, topics.topic_creator, topics.topic_role,topics.topic_details, topics.post_timestamp as pt,posts.post_title, posts.mod_id as mp, posts.post_creator, posts.post_role,posts.post_details, posts.post_timestamp as pp
from topics inner join posts on topics.topic_id=posts.topic_id where topics.mod_id='$mod' and topics.post_timestamp between '$start' and '$end'" ;


#executing the query2
$result=mysql_query($sql,$myConn) or die("cannot run query <br>$sql").mysql_error();

#if successfull display output
if ($result){



#displaying the table heading.

$list="<table border=\"1\" cellpadding=\"2\" align=\"center\">";
$list .= "<tr style=\" background-color:#6A006A\"><th align=\"center\" style=\" font-style:normal; color:#FFDFFF\">Article Topic</th>";
$list .= "<th style=\" font-style:normal; color:#FFDFFF\">Article Content</th>";
$list .= "<th style=\" font-style:normal; color:#FFDFFF\">Module</th>";
$list .= "<th style=\" font-style:normal; color:#FFDFFF\">Posted By </th>";
$list .= "<th style=\" font-style:normal; color:#FFDFFF\">Role</th>";
$list .= "<th style=\" font-style:normal; color:#FFDFFF\">Date</th>";
$list .="</tr>";
while ($row=mysql_fetch_array($result)) {# displaying table records in a loop
$list .= "<tr>";

$list .="<td>". $row['topic_title']."</td>";
$list .="<td>". $row['topic_details']."</td>";
$list .= "<td>". $row['mt']."</td>";
$list .="<td>".$row['topic_creator']."</td>";
$list .="<td>".$row['topic_role']."</td>";
$list .="<td>" .$row['pt']."</td>";
$list .= "</tr>";
$list .="<tr><td>Replies</td></tr>";
$list .= "<tr>";
$list .="<td>". $row['post_title']."</td>";
$list .="<td>". $row['post_details']."</td>";
$list .= "<td>". $row['mp']."</td>";
$list .= "<td>". $row['post_creator']."</td>";
$list .="<td>".$row['post_role']."</td>";
$list .="<td>" .$row['pp']."</td>";
$list .= "</tr>";

}
mysql_free_result($result);

$list .= "</table>";
Any help will be welcomed. :confused: :(

Fumigator
08-23-2006, 08:33 PM
Do you ever actually echo your $list variable?

husnamina
08-23-2006, 08:44 PM
yes I do like this

echo ($list);

ronverdonk
08-24-2006, 12:45 PM
Are you sure that the mysql_fetch_array 2nd parameter is default set as MYSQL_ASSOC? If not, you will not get an associative array!

Otherwise add this parameter to your fetch, as in:

while ($row=mysql_fetch_array($result, MYSQL_ASSOC))

Ronald :cool:

husnamina
08-24-2006, 01:20 PM
Are you sure that the mysql_fetch_array 2nd parameter is default set as MYSQL_ASSOC? If not, you will not get an associative array!

Otherwise add this parameter to your fetch, as in:

while ($row=mysql_fetch_array($result, MYSQL_ASSOC))



i have included the mysql_assoc still no change, please more suggestions. :(

Fumigator
08-24-2006, 03:13 PM
What does "echo $sql" show you?

ronverdonk
08-24-2006, 04:13 PM
To nbe sure you have any rows selected, put a

print_r($row);
statement after each fetch. That way you can see if there is anything selected and what.

Ronald :cool:

husnamina
08-25-2006, 01:12 AM
What does "echo $sql" show you?

it show that it picks up the right row in the topics table and the 1st reply
its just when it cones to display and loop rounsd that the problem starts.

print_r($row)

when i added this line it prompted a response at list and i thot the way i designed the output was not right so i canged it
to

line 40 while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {
print_r($row);

echo "<tr>";

echo"<td>". $row['topic_title']."</td>";
echo"<td>". $row['topic_details']."</td>";
echo "<td>". $row['mt']."</td>";
echo"<td>".$row['topic_creator']."</td>";
echo"<td>".$row['topic_role']."</td>";
echo"<td>" .$row['pt']."</td>";
echo "</tr>";
$my=$row['topic_title'];
$sql2= "select * from posts where post_title=$my ";
$res2=mysql_query($sql2);
line 55 $count= mysql_num_rows($res2);
for($i=1;$i<=$count;$i++){
echo"<tr><td>Replies</td></tr>";
echo "<tr>";
echo"<td>". $row['post_title']."</td>";
echo"<td>". $row['post_details']."</td>";
echo "<td>". $row['mp']."</td>";
echo "<td>". $row['post_creator']."</td>";
echo"<td>".$row['post_role']."</td>";
echo"<td>" .$row['pp']."</td>";
echo "</tr>";

}
mysql_free_result($result);

echo "</table>";

}

}


echo ("There are no user listings");

}




but i get the following errors

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /disks/diskh/zco/cohaa/public_html/tester1/gen_report.php on line 55
-------------------
Warning: mysql_fetch_array(): 4 is not a valid MySQL result resource in /disks/diskh/zco/cohaa/public_html/tester1/gen_report.php on line 40

thanx.
hmm:confused:

Fumigator
08-25-2006, 02:52 AM
Why aren't you checking for errors on your mysql_query() functions?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum