kendallkamikaze Posted May 15, 2009 Share Posted May 15, 2009 I dont know why <?php $sql="SELECT id,Playername,Password,Description,Points,AcademyLevel,Money,Status,Girlscout,gold,diploma,lastlog,Ad,Email,organize,upness FROM player WHERE id='$id'"; $result=mysql_query($sql); while($r=mysql_fetch_array($result)); { $id=$r["id"]; $Playername=$r["Playername"]; $Password=$r["Password"]; $Description=$r["Description"]; $Points=$r["Points"]; $AcademyLevel=$r["AcademyLevel"]; $Money=$r["Money"]; $Status=$r["Status"]; $GirlScout=$r["GirlScout"]; $gold=$r["gold"]; $diploma=$r["diploma"]; $lastlog=$r["lastlog"]; $Ad=$r["Ad"]; $Email=$r["Email"]; $organize=$r["organize"]; $upness=$r["upness"]; if($organize){ $addon=" ORDER BY $organize $upness"; } if($pid == "$id"){ if($_GET['sortby']){ $sortby=$_GET['sortby']; if($_GET['order']){ $order=$_GET['order']; mysql_query("update player set organize='$sortby',upness='$order' where id='$id'"); print "Successfully edited the organization of your horses."; include "footer.php"; exit; } print "How would you like to sort the horse's <b>$sortby</b> on your page? By:<p><a href='player_estate.php?sortby=$sortby&order=ASC'>Ascending</a><br><a href='player_estate.php?sortby=$sortby&order=DESC'>Descending</a>"; include "footer.php"; exit; } } if($_GET[action] == "changepassword2"){ if($_POST[oldpass] != $Passwordd){print "Wrong old password."; include "footer.php"; exit;} mysql_query("update player set Password='$_POST[newpassword]' where id='$id'"); print "<font color=red>You changed your password.</font> You have been signed out for verification. <a href=index.php> Click here to sign back in.</a><br><br>"; include 'footer.php'; exit;} if($_GET[action] == "changepassword1"){PRINT " <form method=post action=player_estate.php?action=changepassword2> Old Pass:<input type=text name='oldpass'><br> New Pass:<input type=text name='newpassword'><br> <input type=submit value='Change Pass'></form>"; } echo "<font size='5pt' face='comic sans ms'>Welcome to Your Estate $Playername!</font><BR> You Are ID #$id <br><br><br> $Description <br><BR><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/ Share on other sites More sharing options...
mikr Posted May 15, 2009 Share Posted May 15, 2009 Is there a possibility that you aren't setting $id correctly? You may wish to echo $sql to find out what the SELECT statement looks like. If you have access to something like phpMyAdmin, you could do what I often do, which is grab that select statement that you just echoed and try it in phpMyAdmin. Another possibility is that one of your fields is a reserved keyword for mysql. I often hedge against that by using back-quotes (` - usually under the tilda on your keyboard) around all fieldnames (ie `id`,`Playername`,`Password` ...). Other than that, more info on what you're experiencing would be helpful. Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/#findComment-834929 Share on other sites More sharing options...
kendallkamikaze Posted May 15, 2009 Author Share Posted May 15, 2009 well ive got the error worked out but now its not displaying the variables when they are correct :/ Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/#findComment-834931 Share on other sites More sharing options...
mikr Posted May 15, 2009 Share Posted May 15, 2009 Why don't you reshow your code as it now stands and a short comment on expected behavior. Otherwise, I'm not sure if by getting the error worked out, you mean you removed the semi-colon from the while statement or not. Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/#findComment-834934 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 Change $result=mysql_query($sql); To $result=mysql_query($sql) or die(mysql_error()); Any errors from that? Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/#findComment-834954 Share on other sites More sharing options...
Maq Posted May 15, 2009 Share Posted May 15, 2009 What is the exact output? You have some exits; in your code, maybe they're being executed? We need more information. Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/#findComment-835002 Share on other sites More sharing options...
.josh Posted May 15, 2009 Share Posted May 15, 2009 on a side note, if your'e going to assign all of $r's vars to elements like that, use mysql_fetch_assoc instead and just extract($r); Quote Link to comment https://forums.phpfreaks.com/topic/158304-mysql-array-not-working/#findComment-835004 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.