datalee100 Posted July 11, 2007 Share Posted July 11, 2007 I host an online trading card game that has their members play games for cards that they can trade and earn rewards from. Recently, I found a tutorial at my personal site's host for a slot game that you play and if the three pictures match up, the prizes appear. Once coded, I uploaded this page to my server and I got the error of: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/unspoke/public_html/darkfutures/slots.php on line 32 With the coding in question being: <?php if ($one==$two) { if ($two==$three) { echo " <?php echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; ?> ">\n"; if ($one=="images/slots/04.GIF") { echo " <?php echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; ?> ">\n"; } } } ?> But when it's coded like this: <?php if ($one==$two) { if ($two==$three) { echo " <?php include('rand-cards.php')?> \n"; if ($one=="images/slots/04.GIF") { echo " <?php include('rand-cards.php')?> \n"; } } } ?> There's no error, but nothing shows up when the prizes are supposed to show up. That include works on every other normal page and shows a card, while the other code that it took the place of from the first to the second. Is another randomizer script that runs the slots. My question is: Did I do something wrong with my coding and is it possible to use both codes in the echo to achieve the result that I would like? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 echo " <?php no terminator and why do you have to echo that again and again? Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 11, 2007 Share Posted July 11, 2007 As stated by another poster above me, you don't need to use echo multiple times here. If you do something like.. <?php echo' <img src="'.$img_1.' border="0"><br /> <img src="'.$img_2.' border="0"><br /> <img src="'.$img_3.' border="0"><br />'; ?> Should work fine. Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 11, 2007 Share Posted July 11, 2007 And yeah...looks odd...the way you went about your coding method.....and look at the bolded red text.... if ($one==$two) { if ($two==$three) { echo " <?php echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; ?> ">\n"; if ($one=="images/slots/04.GIF") { echo " <?php echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; echo "<img src=" . $special[array_rand($special,1)] . $digits2[array_rand($digits2,1)] . ">\n"; ?> ">\n"; } } } ?> Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 11, 2007 Author Share Posted July 11, 2007 So I should get rid of the php code endings and get rid of the multiple echos and it should work? What about the include? Is there a better way to do that as well? [EDIT] Doing the above steps got me this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /home/unspoke/public_html/darkfutures/slots.php on line 31 Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 11, 2007 Share Posted July 11, 2007 Well, for one, you don't need to close and open php tags all over the place and you can echo/print HTML within the PHP.... <?php if($a == $b) { echo'somethingthing here<br />'; } else { echo'something else<br />'; } $variable = 'myvalue'; $variabletwo = 'othervalue'; ?> Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 12, 2007 Author Share Posted July 12, 2007 So for this: <?php if ($one==$two) { if ($two==$three) { echo " <?php include('rand-cards.php')?> \n"; if ($one=="images/slots/04.GIF") { echo " <?php include('rand-cards.php')?> \n"; } } } ?>[/ If I coded it as: <?php if ($one==$two) { if ($two==$three) { echo " include('rand-cards.php') \n"; if ($one=="images/slots/04.GIF") { echo " include('rand-cards.php') \n"; } } } ?> It would work? Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 12, 2007 Share Posted July 12, 2007 There is no need to echo/print out the include. Doing that will do exactly that. It will output what ever is in parenthesis as text. <?php if ($one == $two) { if ($two == $three) { include('rand-cards.php'); if ($one=="images/slots/04.GIF") { include('rand-cards.php'); } } } ?> Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 12, 2007 Share Posted July 12, 2007 You can combine the two if statements. Also, why are you echoing an include statement? <?php if ($one == $two && $two == $three) { echo "All three cards matched!!"; include('rand-cards.php'); if ($one == "images/slots/04.GIF") { echo "Card one was 04.GIF"; include('rand-cards.php'); } } ?> Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 12, 2007 Author Share Posted July 12, 2007 Yeah... I wasn't too sure about whether or not an echo would produce the extent of the include... I'm not good using the echoes... So, what you're saying with combining them... I'm going to go and try that one. Thanks about the include out of echo stuff! Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 12, 2007 Author Share Posted July 12, 2007 To change the order of viewing the include and the echo, I switched the places of them in the coding and now I get: Parse error: syntax error, unexpected T_ECHO in /home/unspoke/public_html/darkfutures/slots.php on line 31 Should I leave them a certain way? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 12, 2007 Share Posted July 12, 2007 make sure there are semicolons at the end of each line. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 12, 2007 Share Posted July 12, 2007 if the terminator is the prob then that means you forgot terminator before the echo say $x=0 echo 'x'; Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 12, 2007 Author Share Posted July 12, 2007 Oops... There was a runaway semi-colon.... Alright- last question and I promise you will all be done with me! How would I go about putting a space in between two images called by an include? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 12, 2007 Share Posted July 12, 2007 use   Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 12, 2007 Author Share Posted July 12, 2007 Adding that makes the & unexpected and the php breaks... Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 12, 2007 Share Posted July 12, 2007 echo ' '; Quote Link to comment Share on other sites More sharing options...
datalee100 Posted July 12, 2007 Author Share Posted July 12, 2007 Thanks so much everyone! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.