Lamez Posted February 14, 2008 Share Posted February 14, 2008 I downloaded a PM system, becasue I am too lazy to make my own, and on all the pages it came with, I get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub007/sc33591-LWQU/lamezz.info/user/message/inbox.php on line 12 what does that mean? Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/ Share on other sites More sharing options...
Northern Flame Posted February 14, 2008 Share Posted February 14, 2008 it means there was an error.... post inbox.php so that we can see what the error is Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466547 Share on other sites More sharing options...
Lamez Posted February 14, 2008 Author Share Posted February 14, 2008 <? include 'db.php'; print '<div class="box">'; if($session->logged_in) { //Get your private message count //Find the percentage that your inbox is full $sql = mysql_query ("SELECT pm_count FROM users WHERE username='$user'"); $row = mysql_fetch_array ($sql); $pm_count = $row['pm_count']; $percent = $pm_count/'50'; $percent = $percent * '100'; ?> <br> <center> <b><p><a href="inbox.php">Inbox</a> | <a href="compose.php">Compose</a> | <a href="sent.php">Sentbox</a></b> <b><p><? echo "$pm_count"." of 50 Total | "."$percent"."% full"; ?></p></b> </center> <br> <? //This stuff and the while loop will query, see if you have messages or not, and display them if you do $query = "SELECT id, sender, subject, message FROM messages WHERE reciever='$user'"; $sqlinbox = mysql_query($query); //Error thingy, ohh no! Dispaly the error and the query so we can diagnose the problem if there is one if(!$sqlinbox) { ?> <p><? print '$query: '.$query.mysql_error();?></p> <? } //There are no rows found for the user that is logged in, so I guess that means they dont have any messages or maybe its all broken elseif (!mysql_num_rows($sqlinbox) ) { ?> <center><p><b>You have no messages to display</b></p></center> <? } //So if there is not an error, and they apparently do have messages we need to get their information and display it. else { //Ok, Lets center this whole table Im going to make just because I like it like that //Then we create a table 80% the total width with 3 columns The subject is 75% of the whole table, the sender is 120 pixels (should be plenty) and the select checkboxes only get 25 pixels ?> <center> <form name="send" method="post" action="delete.php"> <table width="80%"> <tr> <td width="75%" valign="top"><p><b><u>Subject</u></b></p></td> <td width="120px" valign="top"><p><b><u>Sender</u></b></p></td> <td width="25px" valign="top"><p><b><u>Select</u></b></p></td> </tr> <? //Ok cool, now we stick it all into an array and we will dispaly it now while($inbox = mysql_fetch_array($sqlinbox)) { //These are the variables we have the id of the private message, we have the person who sent the message, we have the subject of the message, and yeah thats it $pm_id = $inbox['id']; $sender = $inbox['sender']; $subject = $inbox['subject']; //So lets show the subject and make that a link to the view message page, we will send the message id through the URL to that page so it can be displayed //And also let the person wee who sent it to them, if you want you can make that some sort of a link to view more stuff about the user, but Im not doing that here, I did it for my game though, pretty much same as the viewmsg.php page but a different page, and with the senders id //And finally the checkboxes that are all stuck into an array and if they are selected we stick the private message id into the array //I will only let my users have a maximum of 50 messages, remeber that ok? Because that's the value I will use later for things ?> <tr> <td width="75%" valign="top"><p><a href="viewmsg.php?msg_id=<? echo $pm_id; ?>"><? echo $subject; ?></a></p></td> <td width="120px" valign="top"><p><? echo $sender; ?></p></td> <td width="25px" valign="top"><input name="pms[]" type="checkbox" value="<? echo $pm_id; ?>"></td> </tr> <? //This ends the while loop } ?> <tr> <td colspan="3"><input type="submit" name="Submit" value="Delete Selected"></td> <td></td> <td></td> </tr> </table> </center> <? //So this ends the else to see if it is all ok and having messages or not } //This ends that first thing that checks if you are logged in or not } else{ include ("../../style/include/cons/member.php"); } print '</div>'; include ("../../style/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466548 Share on other sites More sharing options...
Northern Flame Posted February 14, 2008 Share Posted February 14, 2008 from what i see $user was never established Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466550 Share on other sites More sharing options...
Lamez Posted February 14, 2008 Author Share Posted February 14, 2008 it is from db.php db.php: <? include ("../../style/include/session.php"); include ("../../style/include/cons/head_2.php"); $username = $session->username; $user = $username; ?> Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466553 Share on other sites More sharing options...
Northern Flame Posted February 14, 2008 Share Posted February 14, 2008 try doing this then so we can see a more detailed error report $sql = mysql_query ("SELECT pm_count FROM users WHERE username='$user'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466554 Share on other sites More sharing options...
Lamez Posted February 14, 2008 Author Share Posted February 14, 2008 Unknown column 'pm_count' in 'field list' well now I know, lol thanks Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466557 Share on other sites More sharing options...
Northern Flame Posted February 14, 2008 Share Posted February 14, 2008 lol you're welcome Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466562 Share on other sites More sharing options...
Lamez Posted February 14, 2008 Author Share Posted February 14, 2008 wait, I added the field 'pm_count', and I still get that error Unknown column 'pm_count' in 'field list' Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466563 Share on other sites More sharing options...
Northern Flame Posted February 14, 2008 Share Posted February 14, 2008 try $sql = mysql_query ("SELECT * FROM users WHERE username='$user'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466565 Share on other sites More sharing options...
Lamez Posted February 14, 2008 Author Share Posted February 14, 2008 that did it thanks! Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466568 Share on other sites More sharing options...
Northern Flame Posted February 14, 2008 Share Posted February 14, 2008 you're welcome Quote Link to comment https://forums.phpfreaks.com/topic/91023-what-does-this-mean/#findComment-466569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.