Hi, for one of my projects at uni i have to create a PHP based text game, i am basing mine on the colossal cave game.
i am trying to use the explode function to split my string up into variables to check against my database but am getting the error

Parse error: syntax error, unexpected T_STRING in /var/www/game/game.php on line 15

whenever i put the code in, if anyone could help i would be very grateful.

<?php
require('header.html');
?>
<h1>Game</h1>
<p>Click the help button for more Information on playing!</p><br><br>
<div class=inv> <?php require('inventory.php'); ?> </div> <!-- inv -->
<div class="readout"> <?php require('readout.php'); ?> </div> <!-- readout -->
<div class=desc> <?php require('room_desc.php'); ?> </div> <!-- desc -->
<div class=items> <?php require('items_room.php'); ?> </div> <!-- items -->


<?php
$commands = $_REQUEST['commands'];
$comm = EXPLODE(” ”, $commands);
echo “0 = $comm[0]<br />”;
echo “1 = $comm[1]<br />”;
echo “2 = $comm[2]“;
?>
<form>
<div class=commands>
<form method="POST">
<input type="text" name="commands" size="72" value="">  
<input type="submit" name="submit" value="Go!" /></form>
</div> <!--commands -->

<?php require('footer.html'); ?>

Recommended Answers

All 2 Replies

The quotes that you are using are non-standard.


this wont give you that error:

<?php
require('header.html');
?>
<h1>Game</h1>
<p>Click the help button for more Information on playing!</p><br><br>
<div class=inv> <?php require('inventory.php'); ?> </div> <!-- inv -->
<div class="readout"> <?php require('readout.php'); ?> </div> <!-- readout -->
<div class=desc> <?php require('room_desc.php'); ?> </div> <!-- desc -->
<div class=items> <?php require('items_room.php'); ?> </div> <!-- items -->


<?php
$commands = $_REQUEST['commands'];
$comm = EXPLODE(" ", $commands);
echo "0 = $comm[0]<br />";
echo "1 = $comm[1]<br />";
echo "2 = $comm[2]";
?>
<form>
<div class=commands>
<form method="POST">
<input type="text" name="commands" size="72" value="">  
<input type="submit" name="submit" value="Go!" /></form>
</div> <!--commands -->

<?php require('footer.html'); ?>

thankyou :)
all working now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.