PDA

View Full Version : Code in functions.php wont work


Lesane
02-14-2002, 09:21 AM
I have a while loop that works fine if i use an external script but if i put the code in functions.php then it dont works properly.

If i use this outside script and run it then it displays:

fine
fine
wrong

Outside script:

<?php

require("admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord) or die("Unable to connect to database");
mysql_select_db($dbname) or die("Unable to select database $dbname");


$result = mysql_query("SELECT awardsid,aw,name,url FROM useraward where userid='5'");
while ($awardsp = mysql_fetch_array($result)) {
{
if ($awardsp[awardsid] == $awardsp[aw] ) {
echo "fine<br>";
} else {
echo "wrong";
}

}
}
?>


Now if i use the same script in functions.php then it displays only:

wrong

The functions.php script:

$result = mysql_query("SELECT awardsid,aw,name,url FROM useraward where userid='5'");
while ($awardsp = mysql_fetch_array($result)) {
{
if ($awardsp[awardsid] == $awardsp[aw] ) {
$post[hasaward]="fine";
} else {
$post[hasaward]="wrong";
}

}
}

The only thing thats different is: $post[hasaward]. I've putted $post[hasaward] in the postbit and when i go to a thread then it only displays wrong. Their are currently 3 entry's in the database and he listen to the latest entry, the latest entry is labeled as wrong.

Could someone help me with this code, it should be fine but somehow it wont work. Any help is appreciated, Thanks.

Lesane
02-14-2002, 04:12 PM
Nevermind, i got it working. :up: :)