marklarah Posted August 5, 2008 Share Posted August 5, 2008 My code; <?php mysql_connect("localhost", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); ?> <style type="text/css"> fieldset { border:1px solid green; padding: 1em; font:80%/1 sans-serif; } legend { padding: 0.2em 0.5em; border:1px solid green; color:green; font-size:90%; text-align:left; } label { float:left; width:25%; margin-right:0.5em; padding-top:0.2em; text-align:right; font-weight:bold; } </style> <script type="text/javascript"> function formgo(){ var cnum = document.lform.ops.length; for (i = 0; i <cnum; i++) { if (document.lform.ops[i].checked) { var chkd = document.lform.ops[i].value } } switch (chkd) { <?php while ($row = mysql_fetch_array(mysql_query("SELECT * FROM logins ORDER BY label DESC"))){ //Maybe this bit is a bit iffy? echo 'case "'.$row['name'].'": document.'.$row['name'].'.submit(); break;'; } ?> default: alert(""); } alert(chkd); } </script> <form name="lform"> <fieldset> <legend>Login Forms</legend> <?php while ($row = mysql_fetch_array(mysql_query("SELECT * FROM logins ORDER BY label DESC"))){ echo ' <label for="ops">'.$row['label'].'</label> <input type="radio" name="ops" value="'.$row['name'].'"> <br />'; } ?> <button type="button" onClick="formgo()">Submit</button> </fieldset> </form> <?php while ($row = mysql_fetch_array(mysql_query("SELECT * FROM logins ORDER BY label DESC"))){ $info = explode("|", $row['info']); $num = count($info); if($num % 2 != 0){ echo 'Problem'; }else{ echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">'; $n = 0; while ($n != ($num/2)){ $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; } echo '</form> } } ?> Im sure I could fix this myself, except the page never actually stops loading for me to see what the problem is. If that IS the problem though, then I have no idea how to diagnose it. My only guess would be the php in the middle of the javascript, but I've done the before, and it should work ??? Any ideas? Cheers - Mark EDIT: Sorry, just to let you know what this does is supposed to do, is when i got fed up of all the log in pages for different stuff, I wanted just one page, which uses POST (obviously) to get to other logins, without having to remember all the other the passwords or usernames. The use puts the info into the database. The info array works so if there are 3 fields, one hidden and two non (username and password eg), then they all get turned into hidden fields. You put the name of the field first, then the value, then repeat. so for example: universe|uni18|username|joecool|password|darthvader123 Hope that makes sense... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/ Share on other sites More sharing options...
JonnyThunder Posted August 5, 2008 Share Posted August 5, 2008 Errr, perhaps if you say what the actual problem IS, then people can try and help! Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608507 Share on other sites More sharing options...
marklarah Posted August 5, 2008 Author Share Posted August 5, 2008 Im sure I could fix this myself, except the page never actually stops loading for me to see what the problem is. If that IS the problem though, then I have no idea how to diagnose it. ... In other words, it never stops loading. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608510 Share on other sites More sharing options...
JonnyThunder Posted August 5, 2008 Share Posted August 5, 2008 You could start by stepping through the script and exiting, to see which part is causing the issue. I'd imagine one of your while statements is never exiting. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608514 Share on other sites More sharing options...
marklarah Posted August 5, 2008 Author Share Posted August 5, 2008 Erm...they are $row = mysql_fetch_arrays...yes they do. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608516 Share on other sites More sharing options...
Ace Jon Posted August 5, 2008 Share Posted August 5, 2008 The error is in the last echo of the file. You didn't put "</form>" within apostrophes/quotes, and more importantly, you didn't end the line with a semicolon, therefore it's trying to echo the end of your else and the end of your while, instead of ending the loops. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608517 Share on other sites More sharing options...
marklarah Posted August 5, 2008 Author Share Posted August 5, 2008 Oh bloody hell...how stupid of me. I knew it was something like that! Thanks Although, i've fixed that, but I still have the problem. Its still not loading. I think the error must be somewhere further above, in the javascript bit or around. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608709 Share on other sites More sharing options...
marklarah Posted August 5, 2008 Author Share Posted August 5, 2008 ...It still wont load.... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-608808 Share on other sites More sharing options...
marklarah Posted August 5, 2008 Author Share Posted August 5, 2008 I've looked at everything, yet it still won't load.... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609076 Share on other sites More sharing options...
BioBob Posted August 6, 2008 Share Posted August 6, 2008 Personally, first thing I would do is change the way your SQL statements are set up. Define your sql statements first, then call them as a var. $query "SELECT * FROM users"; $sql = mysql_query($query) or die(mysql_error()); while ($results = mysql_fetch_assoc($sql)) { //code... } Without the "or die(mysql_error())" portion of it, if mysql is kicking back errors, the while loop may never complete, hence infinite... Imagine this: while ($a < 10) { $b++; } That loop will never finish either, but after a while should get a TIMEOUT error... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609098 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Hmm. Ok, I did what you said (one way, i was just copying and pasting). IIt didn't help, but it made me think. Anyway, I found the error. Though now it displays one button, and the frame, it doesn't display the radios o_0? My current code <?php mysql_connect("localhost", "....", "....") or die(mysql_error()); mysql_select_db("....") or die(mysql_error()); ?> <style type="text/css"> fieldset { border:1px solid green; padding: 1em; font:80%/1 sans-serif; } legend { padding: 0.2em 0.5em; border:1px solid green; color:green; font-size:90%; text-align:left; } label { float:left; width:25%; margin-right:0.5em; padding-top:0.2em; text-align:right; font-weight:bold; } </style> <script type="text/javascript"> function formgo(){ var cnum = document.lform.ops.length; for (i = 0; i <cnum; i++) { if (document.lform.ops[i].checked) { var chkd = document.lform.ops[i].value; } } switch (chkd) { <?php $query = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error()); while ($row = mysql_fetch_array($query)){ echo 'case "'.$row['name'].'": document.'.$row['name'].'.submit(); break;'; } ?> default: alert(""); } alert(chkd); } </script> <form name="lform"> <fieldset> <legend>Login Forms</legend> <?php while ($rows = mysql_fetch_array($query)){ //this here doesn't work ? echo ' <label for="ops">'.$rows['label'].'</label> <input type="radio" name="ops" value="'.$rows['name'].'"> <br />'; } ?> <button type="button" onClick="formgo()">Submit</button> </fieldset> </form> <?php while ($row = mysql_fetch_array($query)){ $info = explode("|", $row['info']); $num = count($info); if($num % 2 != 0){ echo 'Problem'; }else{ echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">'; $n = 0; while ($n < ($num/2)){ $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; } echo '</form>'; } } ?> I took the code where it displays the radios, along with the connection info, and it works fine, but not here. Maybe its conflicting with something? Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609469 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Go to your browser, and click view->source. Find the bit where it should have the radio buttons, and tell us what it actually says ---------------- Now playing: Enter Shikari - Sorry You're Not A Winner (Zane Lowe BBC Session) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609471 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Well obviously it says nothing (otherwise it would display)...hmm... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609476 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Okay, now ive just realized, its not displaying the form bit either (the bit with the array) Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609482 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Not necessarily. You might have had an unfinished line that didn't show. Attitude won't get you far on this board. have you tried mysql_num_rows to see if there are actually rows for there to be radio buttons? ---------------- Now playing: Enter Shikari - Acid Nation via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609484 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Okay, first, I didn't realize I was coming across arrogant (sorry)...its just today, stuffs been going on....never mind Secondly good idea, ill try that... And It displays 2 (which is right) Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609487 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Can you please replace the radio button with this: while ($rows = mysql_fetch_array($query)){ print_r($rows); } and tell me what you get there? ---------------- Now playing: Enter Shikari - Return To Energiser (Zane Lowe BBC Session) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609489 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 ... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609490 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 That's really odd...So your query returns 2 rows, but both of them are blank? Something's wrong. That should've at least outputted "array()" ---------------- Now playing: Enter Shikari - Keep It On Ice (Zane Lowe BBC Session) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609492 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 See for yourself: http://img168.imageshack.us/img168/9854/picture2xn8.png Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609496 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Post your current code. ---------------- Now playing: Flyleaf - Fully Alive via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609497 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 <?php connect stuff here ?> <style type="text/css"> fieldset { border:1px solid green; padding: 1em; font:80%/1 sans-serif; } legend { padding: 0.2em 0.5em; border:1px solid green; color:green; font-size:90%; text-align:left; } label { float:left; width:25%; margin-right:0.5em; padding-top:0.2em; text-align:right; font-weight:bold; } </style> <script type="text/javascript"> function formgo(){ var cnum = document.lform.ops.length; for (i = 0; i <cnum; i++) { if (document.lform.ops[i].checked) { var chkd = document.lform.ops[i].value; } } switch (chkd) { <?php $query = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error()); while ($row = mysql_fetch_array($query)){ echo 'case "'.$row['name'].'": document.'.$row['name'].'.submit(); break; '; } ?> default: alert(""); } alert(chkd); } </script> <form name="lform"> <fieldset> <legend>Login Forms</legend> <?php while ($rows = mysql_fetch_array($query)){ print_r($rows); } // echo mysql_num_rows($query); while ($rows = mysql_fetch_array($query)){ print ' <label for="ops">'.$rows['label'].'</label> <input type="radio" name="ops" value="'.$rows['name'].'"> <br />'; } ?> <button type="button" onClick="formgo()">Submit</button> </fieldset> </form> <?php while ($row = mysql_fetch_array($query)){ $info = explode("|", $row['info']); $num = count($info); if($num % 2 != 0){ echo 'Problem'; }else{ echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">'; $n = 0; while ($n < ($num/2)){ $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; } echo '</form>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609504 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 <?php /**connect stuff here**/ $query = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error()); while ($row = mysql_fetch_assoc($query)){ print_r($row); } What does that output? ---------------- Now playing: Flyleaf - All Around Me via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609506 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Right, that displays all the stuff from the table. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609513 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Change all mysql_fetch_array to mysql_fetch_assoc, and try again ---------------- Now playing: Flyleaf - Breathe Today via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/#findComment-609515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.