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
RustyDoorknobs
Forum Newbie
Posts: 15 Joined: Mon Sep 07, 2009 4:50 pm
Post
by RustyDoorknobs » Thu Sep 10, 2009 8:01 pm
I keep getting this error:
Parse error: syntax error, unexpected T_VARIABLE in /home/myavatar/public_html/cardtest2.php on line 18
Heres my code:
Code: Select all
<?php
//Script (c) 2009 http://www.gamebattleshq.com
//include into teamcards
//v1.0
//
//Load in DOM Doc
$u = $_GET["u"]
$stats = new DOMDocument();
$stats_xml = $u . "/stats.xml";
$stats->load( $stats_xml );
//
//Assign tags to vars:
$n = "name";
$xp = "xp";
$w = "wins";
$l = "losses";
$s = "streak";
$p = "place";
$wp = "winPercentage";
$mp = "matchesPlayed";
$r = "reputation";
$lv = "level";
//
//Variable loading function:
function get($tag);
{
$i= $stats->getElementsByTagName($tag);
$s = $i->item(0)->nodeValue;
echo $s
}
//Format for entering a stat:
//USE: * <span id="STATNAME"><?php get($stat) ?></span> *
//
//End of Script.
//Script by Alex Kizer.
get("$n");
?>
SimonMayer
Forum Commoner
Posts: 32 Joined: Wed Sep 09, 2009 6:40 pm
Post
by SimonMayer » Thu Sep 10, 2009 8:12 pm
The problem is on line 17
There should be a semi-colon ; at the end of the line, like so:
the semi-colon stops the PHP code being read as one statement. The problem only becomes apparent when it reads line 18, as "$u = $_GET["u"] $stats = new DOMDocument();" does not make sense.
RustyDoorknobs
Forum Newbie
Posts: 15 Joined: Mon Sep 07, 2009 4:50 pm
Post
by RustyDoorknobs » Fri Sep 11, 2009 7:01 am
I fixed up some stuff but i still get this:
Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/myavatar/public_html/cardtest2.php on line 42
I understand it's in my function, so heres my code:
Code: Select all
<?php
//Script (c) 2009 http://www.gamebattleshq.com
//include into teamcards
//v1.0
//
//Load in DOM Doc
$u = $_GET["u"];
$stats = new DOMDocument();
$stats_xml = $u . "/stats.xml";
$stats->load( $stats_xml );
//
//Assign tags to vars:
$n = "name";
$xp = "xp";
$w = "wins";
$l = "losses";
$s = "streak";
$p = "place";
$wp = "winPercentage";
$mp = "matchesPlayed";
$r = "reputation";
$lv = "level";
//
//Variable loading function:
function get($tag)
{
$i= $stats->getElementsByTagName($tag);
$s = $i->item(0)->nodeValue;
echo $s;
}
get("$n");
?>
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Sep 11, 2009 7:15 am
$stats is not in the function's scope.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Fri Sep 11, 2009 3:22 pm