Page 1 of 2
[SOLVED]Need some help *large code*
Posted: Sun Oct 24, 2004 6:47 am
by Diod
the last switches( act=del and act=edit) arent working properly, they dont show anything
http://users.skynet.be/fa321669/cnhelp.txt
Posted: Sun Oct 24, 2004 7:44 am
by kettle_drum
Hmm. Why not try and seperate your code into more functions and then simply have one switch that controls which function will be called. The codes a bit messy at the moment, but im sure that i see you declairing a function in the middle of a switch statment, and then also using a switch with only one option - you can simply use an if statment there instead.
Its hard to say without indenting the code, but you might have placed the code you expect to run in a segment that isnt run as the conditions arent right.
Posted: Sun Oct 24, 2004 7:49 am
by Diod
if i understand you clear, you want me to define functions and then to run these functions where needed?
Posted: Sun Oct 24, 2004 8:27 am
by John Cartwright
File does not exists, use the [ PHP] TAGS
Posted: Sun Oct 24, 2004 9:55 am
by Diod
sry, cant post it, 500 error message, even with edit
try looking
http://codedump.nutextonline.com/view/412
Posted: Sun Oct 24, 2004 11:06 am
by John Cartwright
I dont have time to look through the code right now but I noticed you mispelled mysl_error at one point, also I recommend removing all the @ because they silence the errors.
To debug your script trying echoing things to see if the script reaches a certain point, for example,
($auth->logged_in) {
echo 'it got here';
switch (@$_GET['action']) {
This will isolate the problem, it looks like $auth_logged_in is returning FALSE, therfor the switch never goes run. Also, try putting in a default to see if it is being run
Posted: Sun Oct 24, 2004 11:24 am
by Diod
$auth_logged_in is returning TRUE as i can access the other functions, such as deleting members, etc
btw the echo did say it "got here"
oh and i dont know where i spelled mysl_error wrong?
Posted: Sun Oct 24, 2004 11:31 am
by John Cartwright
Line 143
Posted: Sun Oct 24, 2004 11:35 am
by Diod
Code: Select all
$result = mysql_query($query,$db) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " .$query. "<br />\nError: (" .mysql_errno(). ") " .
mysql_error());
?
mysql_errno is for the number of the error and mysql_error is just the error itself
Posted: Sun Oct 24, 2004 12:26 pm
by John Cartwright
Well I feel stupid, never knew that and never seen it done
Posted: Sun Oct 24, 2004 12:47 pm
by Diod
no big deal

Posted: Sun Oct 24, 2004 1:57 pm
by timvw
an excellent KISS scenario. this sort of script shows why i prefer to have one script for each task.
Code: Select all
$admin = (@$_POST['admin'] == 'true' ? true : false);
does this mean people can "decide" they want to become an admin?
Sure the .tpl files don't have a call do die() ?
Posted: Sun Oct 24, 2004 2:14 pm
by kettle_drum
Go bored and look through the script.
1) Dont put the br2nl function in the switch.
2) Dont put anything inside of the switches except function calls - so take out all your code from them and put them in functions.
3) You write over the $result var. You put the results in it at the start of the code, and then do a while() on them at about line 140 and then write over that var inside of the loop.
4) Dont keep using echos on each line, you can just use one and put all the text in it:
Just start to clean your code up or you will never find the error.
Posted: Tue Oct 26, 2004 12:37 pm
by Diod
ok ill do it right now...

thx
EDIT: i edited it, here is the link
http://users.skynet.be/fa321669/cnhelp.txt
Posted: Tue Oct 26, 2004 1:47 pm
by Diod