smithygotlost Posted October 13, 2007 Share Posted October 13, 2007 Ok i been working on a big online rpg project for the past year now :S i made everything so it worked but didnt look professional ! so now its clean up time i have a private msg feature where people can msg each other the problem is if i for example try and pull msg 12 like so $reply = mysql_query("SELECT * FROM mail WHERE id=$id"); if (!$read) { print "<center><table cellpadding=0 cellspacing=0 width=600>"; print "<tr><td width=20% class=mail-title>From</td><td width=20% class=mail-title>Subject</td></tr>"; $msel = mysql_query("select * from mail where owner=$stat[id] order by id desc limit 15"); while ($mail = mysql_fetch_array($msel)) { print "<tr><td class=mail valign=bottom>"; if ($mail[unread] == T) { print "<b>"; } print "$mail[sender]</b></td><td class=mail valign=bottom>"; if ($mail[unread] == T) { print "<b>"; } mysql_query("update mail set unread='F' where owner=$stat[id]"); print "[<a href=\"pmessage.php?view=$mail[id]\">$mail[subject]</a>]</b></td>"; } that takes it to pmessage.php like so if($view) { $msel = mysql_query("select * from mail where id=$view[id]"); while ($msg = mysql_fetch_array($msel)) { print" <table border=1 cellpadding=0 cellspacing=8 style=border-collapse: collapse width=100% bgcolor=#333333> <tr> <td width=100% style=padding:3px;> <table border=0> <tr> <td valign=top> </td> <td width=613 valign=top> <table border=1 cellspacing=0 cellpadding=5 width=610> <tr> <td bgcolor=#353535><font size=+1 color=5098D7>$msg[subject] </font></td> </tr> <tr> <td width=100% height=34 style=background-color:#666666 cellpadding=5> <table cellpadding=0 cellspacing=0 border=0> <tr> <td>From : </td> <td>$msg[sender]</td> </tr> </table> </td> </tr> <tr> <td height=128 bgcolor=545454>$msg[body]</td> </tr> </table> </td> </tr> </table> [<a href=\"message.php?view=write&id=$mail[id]\">Reply</a>] [<a href=message.php?message=$mail[id]&step=delete>Delete</a>]</td></table>"; } } but rather than pulling msg 12 it pulls message 1 ??? it wont pull the full id for some reason is it something stupid i missed ? - the db connection is in the header of each page any hints of things i have missed would be helpful thanks mike Quote Link to comment Share on other sites More sharing options...
esukf Posted October 13, 2007 Share Posted October 13, 2007 Is $view an array? How are you getting the variable from the query?? <?php $view = (int) $_GET['view']; $msel = mysql_query("select * from mail where id=$view"); ?> Quote Link to comment Share on other sites More sharing options...
smithygotlost Posted October 13, 2007 Author Share Posted October 13, 2007 when u go through the message page it takes all the msg's from the database ! the next page then uses the view id from the previous page so message.php << does the query message.php << [<a href=\"pmessage.php?view=$mail[id]\">$mail[subject]</a>] pmessage.php << if($view) { $msel = mysql_query("select * from mail where id=$view[id]"); while ($msg = mysql_fetch_array($msel)) { grabs the data from the database where the id of the mail is the $view[id] as the top says ?view=$mail[id] so if mail id = 23 the the query should grab the message with id 23 but grabs the message with id 2 lol Quote Link to comment Share on other sites More sharing options...
esukf Posted October 13, 2007 Share Posted October 13, 2007 Sorry, my question should be where you are getting the value for the $view variable. You should on you pmessage.php page have something like the following to grab the view value from the querystring pmessage.php?view=23. <?php $view = $_GET['view']; //23 ?> I think why you are just getting only the first value is this:- <?php $view = "23"; //Your view string value echo $view['id']; //2 //You are trying to get the value as an associative array but $view is a string. //$view['id'] is interpreted as $view[0] so just returns the first character. ?> So to fix your problem either have:- <?php $view = $_GET['view']; $msel = mysql_query("select * from mail where id=$view"); ?> or <?php $view['id'] = $_GET['view']; $msel = mysql_query("select * from mail where id=$view[id]"); ?> Quote Link to comment Share on other sites More sharing options...
smithygotlost Posted October 14, 2007 Author Share Posted October 14, 2007 ?? anyone Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2007 Share Posted October 14, 2007 As has been asked.... where do you define $view? Quote Link to comment Share on other sites More sharing options...
smithygotlost Posted October 14, 2007 Author Share Posted October 14, 2007 im so confused right now lol im probally wrong but i dont think i have a define what in the message.php its just a simple link the sends them to pmessage.php?$view[id] on the pmessage page it just tells it to grab data from the database with the id of $view[id] which is in the address Quote Link to comment Share on other sites More sharing options...
smithygotlost Posted October 15, 2007 Author Share Posted October 15, 2007 ????? Quote Link to comment Share on other sites More sharing options...
smithygotlost Posted October 15, 2007 Author Share Posted October 15, 2007 someone help a noobie out please Quote Link to comment Share on other sites More sharing options...
esukf Posted October 16, 2007 Share Posted October 16, 2007 Have you actual tried the piece of code i wrote before? Anyway, here's the full code you can try. <?php $view = $_GET['view']; if($view) { $msel = mysql_query("select * from mail where id=$view"); //$view NOT $view['id'] while ($msg = mysql_fetch_array($msel)) { print" <table border=1 cellpadding=0 cellspacing=8 style=border-collapse: collapse width=100% bgcolor=#333333> <tr> <td width=100% style=padding:3px;> <table border=0> <tr> <td valign=top> </td> <td width=613 valign=top> <table border=1 cellspacing=0 cellpadding=5 width=610> <tr> <td bgcolor=#353535><font size=+1 color=5098D7>{$msg['subject']} </font></td> </tr> <tr> <td width=100% height=34 style=background-color:#666666 cellpadding=5> <table cellpadding=0 cellspacing=0 border=0> <tr> <td>From : </td> <td>{$msg['sender']}</td> </tr> </table> </td> </tr> <tr> <td height=128 bgcolor=545454>{$msg['body']}</td> </tr> </table> </td> </tr> </table> [<a href=\"message.php?view=write&id={$mail['id']}\">Reply</a>] [<a href=message.php?message={$mail['id']}&step=delete>Delete</a>]</td></table>"; } } ?> Quote Link to comment Share on other sites More sharing options...
smithygotlost Posted October 16, 2007 Author Share Posted October 16, 2007 I LOVE YOU Quote Link to comment 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.