[SOLVED]Need some help *large code*

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

[SOLVED]Need some help *large code*

Post by Diod »

the last switches( act=del and act=edit) arent working properly, they dont show anything

http://users.skynet.be/fa321669/cnhelp.txt
Last edited by Diod on Wed Oct 27, 2004 8:26 am, edited 1 time in total.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

if i understand you clear, you want me to define functions and then to run these functions where needed?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

File does not exists, use the [ PHP] TAGS
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

sry, cant post it, 500 error message, even with edit

try looking http://codedump.nutextonline.com/view/412
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Line 143
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Well I feel stupid, never knew that and never seen it done
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

no big deal :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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() ?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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:

Code: Select all

echo "
several
lines
of
text
";
Just start to clean your code up or you will never find the error.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

ok ill do it right now... :)
thx

EDIT: i edited it, here is the link http://users.skynet.be/fa321669/cnhelp.txt
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

Post Reply