kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 Here's my take on your code. Please note the two lines I commented out and the comments/questions I entered on the line. <?php $strTitle = "Complaints/Reports"; define('QUADODO_IN_SYSTEM', true); require_once('includes/header2.php'); $qls->Security->check_auth_page('complaints.php'); $tmp = array(); $tmp[] = '<h2>Complaints/Reports</h2>'; $tmp[] = '<form name="action" id="action" method="post" action="commentsdelete.php">'; include ('config.php'); // $query=trim(mysql_real_escape_string($query)); <-- What's this? $query = "SELECT * FROM vc_comments WHERE username='admin' ORDER BY `id` DESC LIMIT 0,9"; $result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); // mysql_close(); <-- not needed, infact probably shouldn't be here at all if (mysql_num_rows > 0) while ($rw = mysql_fetch_assoc($result)) { $tmp[] = '<table border="0" width="100%" cellpadding="0" cellspacing="0" class="table">'; $tmp[] = '<tr>'; $tmp[] = '<td width="20"><input type="checkbox" id="' . $rw['id'] . '" value="' . $rw['id'] .'" name="' . $rw['id'] . '"></td>'; $tmp[] = '<td width="30%" align="center">'; $tmp[] = '<a href="../profile/' . $rw['from'] . '">' . $rw['from'] . '</a><br>' . $rw['date'] . '<br>'; $tmp[] = '<a href="commentsadd.php?u=' . $rw['from'] . '">[ Reply ]</a>'; $tmp[] = '</td>'; $tmp[] = '<td width="70%">'; $tmp[] = $rw['message']; $tmp[] = '</td></tr></table>'; $tmp[] = '<p>'; } $tmp[] = '<input type="submit" name="delete" id="delete" value="Delete Comments">'; $tmp[] = '</form>'; echo implode("\n",$tmp)."\n"; include ('includes/footer.php'); ?> Ken Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461914 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 Ken- even with the mysql_close and escape string gone and the code re-arranged only the delete button shows the form will not ??? Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461945 Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 Sorry, change this line <?php if (mysql_num_rows > 0) ?> to <?php if (mysql_num_rows($result) > 0) ?> Ken Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461948 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 ken- still not showing ??? Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461955 Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 If the form isn't showing, then there are no rows being fetched. Put in an echo statement to show the number of rows fetched: <?php $strTitle = "Complaints/Reports"; define('QUADODO_IN_SYSTEM', true); require_once('includes/header2.php'); $qls->Security->check_auth_page('complaints.php'); $tmp = array(); $tmp[] = '<h2>Complaints/Reports</h2>'; $tmp[] = '<form name="action" id="action" method="post" action="commentsdelete.php">'; include ('config.php'); $query = "SELECT * FROM vc_comments WHERE username='admin' ORDER BY `id` DESC LIMIT 0,9"; $result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); echo 'Number of rows fetched = ' . mysql_num_rows($result) . "<br>\n"; // <-- insert this statement if (mysql_num_rows($result) > 0) { while ($rw = mysql_fetch_assoc($result)) { $tmp[] = '<table border="0" width="100%" cellpadding="0" cellspacing="0" class="table">'; $tmp[] = '<tr>'; $tmp[] = '<td width="20"><input type="checkbox" id="' . $rw['id'] . '" value="' . $rw['id'] .'" name="' . $rw['id'] . '"></td>'; $tmp[] = '<td width="30%" align="center">'; $tmp[] = '<a href="../profile/' . $rw['from'] . '">' . $rw['from'] . '</a><br>' . $rw['date'] . '<br>'; $tmp[] = '<a href="commentsadd.php?u=' . $rw['from'] . '">[ Reply ]</a>'; $tmp[] = '</td>'; $tmp[] = '<td width="70%">'; $tmp[] = $rw['message']; $tmp[] = '</td></tr></table>'; $tmp[] = '<p>'; } $tmp[] = '<input type="submit" name="delete" id="delete" value="Delete Comments">'; } $tmp[] = '</form>'; echo implode("\n",$tmp)."\n"; include ('includes/footer.php'); ?> Ken Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461962 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 no rowsbeing fetched ??? Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461975 Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 That's why the form isn't being displayed. Now you have to figure out why no rows are being fetched. Ken Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-461979 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 why would thhey not be fetched though ??? Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-462013 Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 I don' t know. You have to check your query SELECT * FROM vc_comments WHERE username='admin' ORDER BY `id` DESC LIMIT 0,9 manually against your database. If you have phpmyadmin, use that. Without access to your database, we can't help you. Ken Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-462021 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 i think WHERE username='admin' is throwing it off because there is no comment by admin. this is horribly designed or was. Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-462027 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 for some odd reason i think it is not connecting ot the database even though i called the config file which connects to it ??? anyone got ideas about this ??? Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-462103 Share on other sites More sharing options...
darkfreaks Posted February 8, 2008 Author Share Posted February 8, 2008 okay can someone tell me why the following code works on another page? and fetches rows but does not on my current code? <?php $strTitle = "Your Comments"; define('QUADODO_IN_SYSTEM', true); require_once('includes/header2.php'); $qls->Security->check_auth_page('comments.php'); $logname = stripslashes($qls->user_info['username']); echo "Recieved Comments | <a href=\"commentssent.php\">Sent Comments</a> | somthing else soon <h2>Your Comments</h2> <form name=\"action\" id=\"action\" method=\"post\" action=\"commentsdelete.php\"> "; include ('config.php'); $query=trim(mysql_real_escape_string($query)); $query = "SELECT * FROM vc_comments WHERE username='$logname' AND inbox='' ORDER BY `id` DESC LIMIT 0,9"; $result = mysql_query($query); $num=mysql_num_rows($result) or die(mysql_error()); $i=0; for ($i = 0; $i < $num; $i++) { $id = mysql_result($result,$i,"id"); $from = mysql_result($result,$i,"fname"); $date = mysql_result($result,$i,"date"); $dpic = mysql_result($result,$i,"dpic"); $message = mysql_result($result,$i,"message"); { echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"table\"> <tr> <td width=\"20\"><input type=\"checkbox\" id=\"$id\" value=\"$id\" name=\"$id\"></td> <td width=\"30%\" align=\"center\"> <a href=\"../profile/$from\">"; if (empty($dpic)) { echo ""; }else{ echo "<img src='gallery/$dpic' border='0' class='thumbnail2'>"; }; echo "<br>$from</a><br>"; $users = $qls->online_users(); $online_count = count($users); $online = false; for ($x = 0; $x < $online_count; $x++) { if ($users[$x]['username'] == $from) { $online = true; break; } } if ($online === true) { echo "<font color='Lime'>[Online]</font>"; } else { echo "<font color='Red'>[Offline]</font>"; } echo "<br>$date<br> <a href=\"commentsadd.php?u=$from\">[ Reply ]</a> </td> <td width=\"70%\"> $message </td></tr></table> <hr>"; }; }; mysql_close(); echo "<input type=\"submit\" name=\"delete\" id=\"delete\" value=\"Delete Comments\"> </form>"; include ('makecommentsold.php'); include ('includes/footer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/89652-solved-form-does-not-show/page/2/#findComment-462166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.