Help please

For discussions about game development that does not fit in any of the other topics.
Post Reply
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Help please

Post by pretender5552 »

Hey I need a bit of help I am trying to get this simple php set up to show my stats like health / max health but I am getting an error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\wamp\www\cyberwars\playerstats.php on line 14

Code: Select all

<?php

$playerinfo="SELECT * from players where name='Bryan'";
$playerinfo2=mysql_query($playerinfo) or die((mysql_error));
$playerinfo3=mysql_fetch_array($playerinfo2);

$playerhealth = $playerinfo3['health'];
$playertech = $playerinfo3['tech'];
$playerenergy = $playerinfo3['energy'];
$playermaxhealth = $playerinfo3['maxhealth'];
$playermaxtech = $playerinfo3['maxtech'];
$playermaxenergy = $playerinfo3['maxenergy'];

echo $playerhealth . "/" . $playermaxhealth "     " $playertech . "/" . $playermaxtech "       " $playerenergy . "/" . $playermaxenergy;

?>
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Help please

Post by Jackolantern »

You need to fix this line:

Code: Select all

echo $playerhealth . "/" . $playermaxhealth "     " $playertech . "/" . $playermaxtech "       " $playerenergy . "/" . $playermaxenergy;
You need to have periods next to $playermaxhealth and $playertech. Right next you just have a string literal next to variables with no concatenation operator.
The indelible lord of tl;dr
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: Help please

Post by pretender5552 »

Thanks and this is just to make sure I have it work so far I will be adding more coding to it later
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Help please

Post by Callan S. »

concatenation
I've heard if you say this three times in front of a mirror, an evil spirit appears.......
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: Help please

Post by pretender5552 »

Alright now for some reason my text is appearing on the div but I am trying to get it below it

Code: Select all

<?php
include_once 'connect.php';
include_once 'div.php';
include_once 'div2.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="right">
</div>
<?php

$playerinfo="SELECT * from player where name='Bryan'";
$playerinfo2=mysql_query($playerinfo) or die((mysql_error()));
$playerinfo3=mysql_fetch_array($playerinfo2);

$playerlevel = $playerinfo3['level'];

echo "<font color='ffffff'><b> Level: " . $playerlevel . "</font></b>";

?>
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Help please

Post by Chris »

You are closing your <b> tag before your <font> tag. But your <font> tag was opened first. The <b> and <font> tags are both also not used anymore. We now use <strong> instead of <b>. And a span with CSS to give colours:

Code: Select all

echo "<span style=\"color: #FFF; font-weight: bold;\"> Level: " . $playerlevel . "</span>";  
Fighting for peace is declaring war on war. If you want peace be peaceful.
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: Help please

Post by pretender5552 »

Thanks managed to get it, also I want to add a border to my second div but a border of 1 is to big is there anyway I can make it smaller?
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Help please

Post by Chris »

the smallest border you can put on is 1px.

Code: Select all

<div style="border: #F00 1px solid;">The is a div with a border</div>
Fighting for peace is declaring war on war. If you want peace be peaceful.
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: Help please

Post by pretender5552 »

Yeah got it had my cellspacing to 20 and didn't notice sorry
pretender5552
Posts: 127
Joined: Mon Jan 03, 2011 5:38 am

Re: Help please

Post by pretender5552 »

Thanks for the help this is what I have so far still need to and in the experience bar, plus news, and shout box so players can talk to each other

Image
Post Reply

Return to “General Development”