MadnessRed Posted March 7, 2009 Share Posted March 7, 2009 can I suggest against the use of a while loop in this situation? if there is only 1 row you really don't need a loop. Also try this print_r($row); add it just after $row = mysql_fetch_array($result); <?php /*DATABASE SETTINGS */ $user_id = (int)$_GET["user_id"]; $type = $_GET["type"]; $username = mysql_real_escape_string($_SESSION['username']); $query = "SELECT user_id FROM users WHERE username = '$username'"; $result = mysql_query($query); list($own_id) = mysql_fetch_row($result); $query = "SELECT COUNT(user_id) FROM users WHERE user_id='$user_id' ORDER BY u.ammount DESC"; $result = mysql_query($query); list($rang) = mysql_fetch_row($result); $user_id = mysql_real_escape_string($user_id); if(isset($user_id)) { $query = "SELECT * FROM users WHERE user_id = '$user_id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); switch($type){ case 'info': $text = "<table border='0'><tr><td colspan='2'><CENTER>INFO OVER {$row['user_name']}</CENTER></TD></TR> <tr><td>forum Naam:</td><td><b>{$row['forum_name']}</b></td></tr> <tr><td>e-mail:</td><td><b>{$row['email']}</b></td></tr> <tr><td>telefoon:</td><td><b>{$row['tel']}</b></td></tr> <tr><td>woonplaats:</td><td><b>{$row['place']}</b></td></tr> <tr><td>leeftijd:</td><td><b>{$row['age']}</b></td></tr> <tr><td colspan='2'></td></tr> <tr><td>Aantal posts:</td><td><b>{$row['ammount']}</b></td></tr> <tr><td>ranglijst:</td><td><b>{$rang}</b></td></tr> </table>"; break; case 'edit': if($user_id == $own_id) { $forumch = $_POST["forumch"]; if(isset($forumch)) { $forum = $_POST['forum']; $query = "UPDATE users SET forum_name = '$forum' WHERE user_id = '$user_id'"; $result = mysql_query($query); if(isset($_POST['emailch'])) { $forum = $_POST['email']; $query = "UPDATE users SET email = '$email' WHERE user_id = '$user_id'"; $result = mysql_query($query); } if(isset($_POST['telch'])) { $forum = $_POST['tel']; $query = "UPDATE users SET forum_name = '$tel' WHERE user_id = '$user_id'"; $result = mysql_query($query); } if(isset($_POST['placech'])) { $forum = $_POST['place']; $query = "UPDATE users SET forum_name = '$place' WHERE user_id = '$user_id'"; $result = mysql_query($query); } if(isset($_POST['agech'])) { $forum = $_POST['age']; $query = "UPDATE users SET forum_name = '$age' WHERE user_id = '$user_id'"; $result = mysql_query($query); } $text=" <form action='' method='post'><table border='0'><tr><td colspan='2'><CENTER>VERANDER JE PROFIEL</td></tr> <tr><td>Forum Naam:</td><td><textarea name='forum' cols='40' rows='1'>{$row['forum_name']}</textarea><input type='submit' value='change' name='forumch'></td></tr> <tr><td>Email:</td><td><textarea name='email' cols='40' rows='1'>{$row['email']}</textarea><input type='submit' value='change' name='emailch'></td></tr> <tr><td>telefoon:</td><td><textarea name='tel' cols='40' rows='1'>{$row['tel']}</textarea><input type='submit' value='change' name='telch'></td></tr> <tr><td>Woonplaats:</td><td><textarea name='place' cols='40' rows='1'>{$row['place']}</textarea><input type='submit' value='change' name='placech'></td></tr> <tr><td>Leeftijd:</td><td><textarea name='age' cols='40' rows='1'>{$row['age']}</textarea><input type='submit' value='change' name='agech'></td></tr> </table></form>"; }else{ $text = " You don't have acces to this account, if it is yours,<br> 1) <a href='4ade.uuuq.com/login.php'>login</a><br> 2) <a href='4ade.uuuq.com/forum'>Meld een probleem aan de administrator op het forum</a><p> If it isn't yours,<br> 1) <a href='4ade.uuuq.com/members.php?user_id={$user_id}&type=info'>go to the info page from {$row['user_name']}</a><br> 2) <a href='4ade.uuuq.com/index.html'>Go to the home page</a><br> "; } $text = "Sorry there has went something wrong.<p> <a href='4ade.uuuq.com/index.html'>go to the homepage</a><br> <a href='4ade.uuuq.com/members.php?user_id={$user_id}&type=info'>go to the info page from {$row['user_name']}</a><br> <a href='4ade.uuuq.com/help.php'>go to the help-page</a>"; } break; } } ?> <html dir="ltr"> <head> <title>MEMBERS</title> <link href="../../standard.css" type="text/css" rel="stylesheet" /> <link href='dichtkunst.css' type='text/css' rel="stylesheet" /> </head> <body> <table class="look" height="100%" width="100%" border="1"> <tbody> <tr> <td width="10%" height="100%"><iframe class="frames" src="../../functieknoppen/functieknoppendichtkunst.htm" frameborder="0" width="100%" height="100%" scrolling="no"></iframe> </td> <td><center> <?php echo $text; ?> </center></td> </tr> </tbody> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-778882 Share on other sites More sharing options...
DEVILofDARKNESS Posted March 7, 2009 Author Share Posted March 7, 2009 If I do print_r it gives me this: Array ( [0] => 3 [user_id] => 3 [1] => test [user_name] => test [2] => 3 [ammount] => 3 [3] => 1f8582c31b117c4449c6cbf86bf406ae [user_pass] => 1f8582c31b117c4449c6cbf86bf406ae [4] => 2009-03-07 [last_login] => 2009-03-07 [5] => [forum_name] => [6] => => [7] => [tel] => [8] => [place] => [9] => 0 [age] => 0 ) Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-778893 Share on other sites More sharing options...
kickstart Posted March 7, 2009 Share Posted March 7, 2009 Hi Appears that they are blank fields on the database, hence nothing to actually put in the textareas. All the best Keith Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-778901 Share on other sites More sharing options...
MadnessRed Posted March 7, 2009 Share Posted March 7, 2009 [forum_name] => [email] => [tel] => [place] => Those are the problematic fields, check the database as you will probably see the those fields are empty. Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-778998 Share on other sites More sharing options...
DEVILofDARKNESS Posted March 8, 2009 Author Share Posted March 8, 2009 yes, they were, thannks Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-779628 Share on other sites More sharing options...
MadnessRed Posted March 8, 2009 Share Posted March 8, 2009 kl, btw did you remove the loop? Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-779663 Share on other sites More sharing options...
DEVILofDARKNESS Posted March 8, 2009 Author Share Posted March 8, 2009 Na, I didn't. If I would, would it be mysql_fetch_row instead of mysql_fetch_array??? It works with the loop, but if it is better without can you expain how to do that??? Thanks Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-779708 Share on other sites More sharing options...
MadnessRed Posted March 8, 2009 Share Posted March 8, 2009 no it would be mysql_fetch_array<?php jsut replace while($row = mysql_fetch_array($result)){ ... } with $row = mysql_fetch_array($result); ... Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-779732 Share on other sites More sharing options...
kickstart Posted March 8, 2009 Share Posted March 8, 2009 Hi Or if you are not certain it will bring back a record then replace the while with an if. All the best Keith Link to comment https://forums.phpfreaks.com/topic/147621-solved-problem-cant-find-fault/page/2/#findComment-779753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.