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
HomerTheDragoon
Forum Newbie
Posts: 21 Joined: Sat Jul 08, 2006 2:10 am
Post
by HomerTheDragoon » Sun Jul 09, 2006 12:37 pm
it says error on line 41 unexpected }
Code: Select all
if (isset($_POST['mode'])) {
$mode=$_POST['mode'];
} else {
$mode="petstats";}
$directory="http://clangg.com/gmpets/";
$un="gmpets";
$pw="0482";
$database="gmpets";
$hostname="mysql141.secureserver.net";
mysql_connect($hostname,$un,$pw);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT * FROM gmpets_accounts";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i<$num){
if ($user_name==mysql_result($result,$i,"username")){
$stats[0]=mysql_result($result,$i,"strength");
$stats[1]=mysql_result($result,$i,"intelligence");
$stats[2]=mysql_result($result,$i,"agility");
$stats[3]=mysql_result($result,$i,"speed");
$stats[4]=mysql_result($result,$i,"defence");
$stats[5]=mysql_result($result,$i,"hp");
$pet=mysql_result($result,$i,"pet");
$login=1;}
$i++;
}
if ($login==1 && $mode=="petstats"){
if ($pet="nopet"){
echo "Pet type: $pet";
?>
<form action="http://clangg.com/modules.php?name=Nreplays" method="post">
<input type="hidden" name="mode" value="newpet">
<input type="submit" value="Register a pet">
</form>
<?
}} /// line 41
if ($login==1 && $mode=="petstats" && $pet!=="nopet"){
echo "Pet type: $pet<br>";
echo "Strength: $stats[0]<br>";
echo "Intelligence: $stats[1]<br>";
echo "Agility: $stats[2]<br>";
echo "Speed: $stats[3]<br>";
echo "Defence: $stats[4]<br>";
echo "HP: $stats[5]<br>";
}
if ($login==0){
echo "sorry you have to be registered to have a pet.";}
mysql_close();
?>
HomerTheDragoon
Forum Newbie
Posts: 21 Joined: Sat Jul 08, 2006 2:10 am
Post
by HomerTheDragoon » Sun Jul 09, 2006 12:46 pm
no its not the same, i just took out half the code, because ik atm its not causeing it. I had it working, then i wrote like about 20 more lines, and i ran into a problem.
heres the full code.
Code: Select all
if (isset($_POST['mode'])) {
$mode=$_POST['mode'];
} else {
$mode="petstats";}
$directory="http://clangg.com/gmpets/";
$un="gmpets";
$pw="0482";
$database="gmpets";
$hostname="mysql141.secureserver.net";
mysql_connect($hostname,$un,$pw);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT * FROM gmpets_accounts";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i<$num){
if ($user_name==mysql_result($result,$i,"username")){
$stats[0]=mysql_result($result,$i,"strength");
$stats[1]=mysql_result($result,$i,"intelligence");
$stats[2]=mysql_result($result,$i,"agility");
$stats[3]=mysql_result($result,$i,"speed");
$stats[4]=mysql_result($result,$i,"defence");
$stats[5]=mysql_result($result,$i,"hp");
$pet=mysql_result($result,$i,"pet");
$login=1;}
$i++;
}
if ($login==1 && $mode=="petstats"){
if ($pet="nopet"){
echo "Pet type: $pet";
?>
<form action="http://clangg.com/modules.php?name=Nreplays" method="post">
<input type="hidden" name="mode" value="newpet">
<input type="submit" value="Register a pet">
</form>
<?
}}
if ($login==1 && $mode=="petstats" && $pet!=="nopet"){
echo "Pet type: $pet<br>";
echo "Strength: $stats[0]<br>";
echo "Intelligence: $stats[1]<br>";
echo "Agility: $stats[2]<br>";
echo "Speed: $stats[3]<br>";
echo "Defence: $stats[4]<br>";
echo "HP: $stats[5]<br>";
}
if ($login==0){
echo "sorry you have to be registered to have a pet.";}
if ($login==1 && $mode=="newpet"){
$query="SELECT * FROM gmpets_accounts";
$result=mysql_query($query);
$num=mysql_numrows($result);
if (isset($_Post['idnumber']{
$idnumber=$_POST['idnumber'];}
else {idnumber=0;}
$max=$idnumber+9;
$int=0;
while ($int<9){
$pet[$int]=mysql_result($result,$i+$int,"name");
}
?>
<table border="0" bordercolor="" width="10" bgcolor="">
<tr>
<td><?echo "$directory$pet[0].gif";?></td>
<td><?echo "$directory$pet[1].gif";?></td>
<td><?echo "$directory$pet[2].gif";?></td>
</tr>
<tr>
<td><?echo "$directory$pet[3].gif";?></td>
<td><?echo "$directory$pet[4].gif";?></td>
<td><?echo "$directory$pet[5].gif";?></td>
</tr>
<tr>
<td><?echo "$directory$pet[6].gif";?></td>
<td><?echo "$directory$pet[7].gif";?></td>
<td><?echo "$directory$pet[8].gif";?></td>
</tr
</table>
<?
}
mysql_close();
?>
Charles256
DevNet Resident
Posts: 1375 Joined: Fri Sep 16, 2005 9:06 pm
Post
by Charles256 » Sun Jul 09, 2006 1:31 pm
one. Learn to indent your code.
Code: Select all
//incorrect
if(something){do some crap
if(something){do some more crap}else{do some crap}boo}
//correct
if(something)
{
do some crap
if(something)
{
do some more crap
}
else
{
do some crap
}
boo
}
see the difference? If I left off a closing brace I could see it easily. not the case with your code.
2. re-write your code like I Just showed you and the error will become self evident.if not, before you say you couldn't find it, post the re-indented code so I cna more easily point it out. yes, i do know where your error is, but I'm trying to help you in th elong run
csingsaas
Forum Newbie
Posts: 22 Joined: Thu Jul 06, 2006 9:34 pm
Location: Edina, MN
Post
by csingsaas » Sun Jul 09, 2006 6:07 pm
I noticed an error in one of your IF statements:
you had:
It should be: