Page 1 of 1

Help please

Posted: Mon Jan 10, 2011 12:40 am
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;

?>

Re: Help please

Posted: Mon Jan 10, 2011 2:12 am
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.

Re: Help please

Posted: Mon Jan 10, 2011 2:26 am
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

Re: Help please

Posted: Mon Jan 10, 2011 5:14 am
by Callan S.
concatenation
I've heard if you say this three times in front of a mirror, an evil spirit appears.......

Re: Help please

Posted: Mon Jan 10, 2011 5:24 am
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>";

?>

Re: Help please

Posted: Mon Jan 10, 2011 6:53 am
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>";  

Re: Help please

Posted: Mon Jan 10, 2011 7:38 am
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?

Re: Help please

Posted: Mon Jan 10, 2011 7:51 am
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>

Re: Help please

Posted: Mon Jan 10, 2011 8:03 am
by pretender5552
Yeah got it had my cellspacing to 20 and didn't notice sorry

Re: Help please

Posted: Mon Jan 10, 2011 8:12 am
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