PDA

View Full Version : a bit of code in need of fixing


E
04-02-2002, 04:19 AM
part of a hack im making:

//Drakks Warning Hack
$warnifield="field10" //make x the field for ur warning level
$warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE $userid=$bbuserinfo");
if ($warnlevel >= "10") {
$warnphraze="NEEDS BANNING"; //u may set the warn phraze for each one
} elseif ($warnlevel >= "7") {
$warnphraze="Very Bad";
} elseif ($warnlevel >= "4") {
$warnphraze="Thats Rough";
} elseif ($warnlevel >= "1") {
$warnphraze="Evil's Apprentice";
} else {
$warnphraze= "Goody Goody";
}
if ($warnfield >= "10") {
$warning='<img src="{imagefolder}/warn1.jpg"> $warnphraze';
} elseif ($warnlevel >= "7") {
$warning='<img src="{imagefolder}/warn2.jpg"> $warnphraze';
} elseif ($warnlevel >= "4") {
$warning='<img src="{imagefolder}/warn3.gif"> $warnphraze';
} elseif ($warnlevel >= "1") {
$warning='<img src="{imagefolder}/warn4.gif"> $warnphraze';
} else {
$warning='<img src="{imagefolder}/warn5.gif"> $warnphraze';
}
//End Warning hack

Theres also an error with the query,,, but... how can i get $warning too =<img src="{imagefolder}/warn5.gif"> and so on?

i know that Wont work.. how can i change it too make it work

TECK
04-02-2002, 05:22 AM
did you tried:$warning='<img src="{imagefolder}/warn1.jpg"> $warnphraze'?

E
04-02-2002, 05:25 AM
hmm...

E
04-02-2002, 05:41 AM
theres still the error with this line :
$warnlevel = $DB_site->query_first("SELECT $warnfield FROM userfield WHERE userid='$bbuserinfo'");

i also tried changing it too:
$warnlevel = $DB_site->query_first("SELECT $warnfield FROM userfield WHERE userid=$userid");

Logician
04-02-2002, 07:26 AM
insert:
echo "warnfield=$warnfield <br>";
echo "bbuserinfo=$bbuserinfo<br>";
before
$warnlevel = $DB_site->query_first("SELECT $warnfield FROM userfield WHERE userid='$bbuserinfo'");

and see what your variables have before entering the query.

BTW isnt it the variable "$bbuserinfo[userid]" you should use in your query if I got what you're trying to do right?

if yes try this:
$new_var_323= $bbuserinfo[userid];
$warnlevel = $DB_site->query_first("SELECT $warnfield FROM userfield WHERE userid='$new_var_323'");

Hope this helps..

Regards,
Logician

E
04-02-2002, 07:33 AM
it seems no matter what i do i get this error:

Parse error: parse error in /home/fiendwor/public_html/admin/functions.php on line 214

Fatal error: Call to undefined function: getuserinfo() in /home/fiendwor/public_html/admin/sessions.php on line 323

E
04-02-2002, 07:36 AM
it doesnt like this code:
echo "warnfield=$warnfield <br>";

if thats not there it doesnt like this code:
$new_var_323= $bbuserinfo[userid];

if thats not there it doesnt like the query

Logician
04-02-2002, 07:48 AM
what editor program do you use? Cant you see which line produced the error? I strongly suggest you using an editor that can show you line numbers and then you can easily point which line is causing you trouble. It would be a real headache to trace and fix the problem without even knowing which line causes the problem!

E
04-02-2002, 07:52 AM
//Drakks Warning Hack
$warnfield="field10" //make x the field for ur warning level
echo "warnfield=$warnfield <br>";
echo "bbuserinfo=$bbuserinfo<br>";

$warnlevel = $DB_site->query_first("SELECT $warnfield FROM userfield WHERE userid='$new_var_323'");
$warnlevel=$warnlevel[$warnfield];

in that case this is the line:
echo "warnfield=$warnfield <br>";

if u get rid of that and the bit after it and this is in there this is the line:
$new_var_323= $bbuserinfo[userid];

but.. if that aint there this is the line:
$warnlevel = $DB_site->query_first("SELECT $warnfield FROM userfield WHERE $bbuserinfo[userid]");

and so on

E
04-02-2002, 08:00 AM
o and the first line of this bit of code is the reference too the sessions.php
// get pertinient user info
if (!isset($bbuserinfo) or $bbuserinfo['userid']!=$session['userid']) {
$bbuserinfo=getuserinfo($session['userid']);
$bbuserinfo['realstyleid'] = $bbuserinfo['styleid'];
}

E
04-02-2002, 07:57 PM
^^

Logician
04-03-2002, 07:07 AM
if your code gives an error in a line like
echo "warnfield=$warnfield <br>";

then you better check your { and }s

This line is a simple PHP code which cant produce any errors, so it is obvious that your problem is something else. Generally wrong use of {}s produce such "awkward" errors and unfortunately they're the hardest ones to trace

E
04-03-2002, 07:35 AM
ok.. ill have a look thru my code now thx

E
04-03-2002, 07:41 AM
Lol.. .i dont know how... but all of a sudden my code works...
damn thats amazing.. i just hope the rest of the hack works

E
04-03-2002, 08:34 AM
aww....****... i found the problem.. i was looking at the wrong sessions.php file (not the one on my site)

Error=
Parse error: parse error in /home/fiendwor/public_html/forum/admin/functions.php on line 214

Fatal error: Call to undefined function: getuserinfo() in /home/fiendwor/public_html/forum/admin/sessions.php on line 323

Here is line 214 on functions.php:
warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE $userid=$bbuserinfo");
^^and ive tried evrything for that line.....

Here is line 323 on sessions.php:
$bbuserinfo=getuserinfo($session['userid']);

U mightve guessed the problem came backk

Logician
04-03-2002, 03:36 PM
parse error is because you missed the $ in the beginning of warnlevel

As for getuserinfo function error well it seems obvious that script cant find your function "getuserinfo". Are you sure it's defined and if it's in another script is it included properly?

E
04-03-2002, 09:18 PM
OK what line would work.... if i want too select field10 from the userfield where the userid is equal to the person it displays for

E
04-04-2002, 07:34 AM
^^^word

E
04-05-2002, 12:41 AM
appreciate any help :(

Logician
04-05-2002, 04:49 AM
Originally posted by E

warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE $userid=$bbuserinfo");
^^and ive tried evrything for that line.....

This query does what you asked:

SELECT field10 FROM userfield WHERE userid=8

so this should work:

$warnifield='field10';
$variable1223=$bbuserinfo['userid'];
$warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE userid='$variable1223');

E
04-05-2002, 06:49 AM
u forgot to close the statement :)
$warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE userid='$variable1223');

=

$warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE userid='$variable1223'");

Anyways... I finally got rid of that error.. so thanks for all ur help i really appreciate it... now i get this errror instead:)

Fatal error: Call to a member function on a non-object in /home/fiendwor/public_html/forum/admin/functions.php on line 215

215:
$warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE userid='$uservar'");

$uservar is instead of variable1223... so i did change it dont worry :)

Logician
04-05-2002, 07:35 AM
Originally posted by E

$warnlevel = $DB_site->query_first("SELECT $warnifield FROM userfield WHERE userid='$uservar'");

Try

$warnlevel = $DB_site->query("SELECT $warnifield FROM userfield WHERE userid='$uservar'");

E
04-05-2002, 07:40 AM
gives the same warning.. damn this is getting nowhere lol... where Firefly with his one post fixes... lol

E
04-06-2002, 05:45 AM
dammit.. i see problems being fixed in a day.. this has been ages:(.. there must be some way to do this

mr e
04-06-2002, 06:12 AM
What happens if you do this?

$warnlevel = $DB_site->query_first("SELECT $warnifield,userid FROM userfield WHERE userid='$uservar'");

E
04-06-2002, 07:56 AM
its not that... the WHERE userid bit.......... The
$uservar = $bbuserinfo['userid']

Dammit it dont recognize that [better wash my mouth][better wash my mouth][better wash my mouth][better wash my mouth]

E
04-06-2002, 07:56 AM
i said bit not [better wash my mouth][better wash my mouth][better wash my mouth][better wash my mouth][better wash my mouth]

mr e
04-07-2002, 01:34 AM
Don't you have to SELECT the userid also? Post what you currently have up to this point.