Danny620 Posted August 23, 2009 Share Posted August 23, 2009 when i run it i just get Parse error: parse error, expecting `','' or `';'' in C:\xampp\htdocs\attack.php on line 22 <?php require('config.php'); ?> <style type="text/css"> <!-- body,td,th { color: #FFFFFF; } body { background-color: #000000; } --> </style><?php //this file will be all in php //if user did not select who to attack, we show him list of users if (!$_GET[attack]) { //we select id and username of everyone except us $q = "SELECT id,username,clan,wins,lose FROM test WHERE id<>'$user[id]'"; $battleQ = mysqli_query ($dbc, $q); echo '<table width="698" border="0" align="center">'; while ($battle = mysqli_fetch_array($battleQ)) { //we show all selected users as well as link to their "attack" subpage echo "<tr> <td width="279"><div align="center">$battle[username]</div></td> <td width="206"><div align="center">$battle[clan]</div></td> <td width="55"><div align="center"><a href=\"profile.php?profile=".$battle[username]."\">attack</a></div></td> <td width="68"><div align="center">$battle[wins]</div></td> <td width="68"><div align="center">$battle[lose]</div></td> </tr>"; } echo '</table>'; } //if user selected link to attack player if ($_GET[attack]) { $attack_id = $_GET[attack]; //we check if ID submited is numerical if (!is_numeric($attack_id)) { die("Bad target ID!"); } //we select user with that ID $q = "SELECT * FROM test WHERE id='$attack_id' LIMIT 1"; $attackQ = mysqli_query ($dbc, $q); $attackR = mysqli_num_rows($attackQ); //we check that rows are 1. if there are zero rows this means user is modifying link so we close our script! if ($attackR <> 1) { die("Bad target ID!"); } //all is fine, we select attacked user $attack = mysqli_fetch_array($attackQ); if($user[turns] <= 0){die("You Have Ran Out of TURNS!!");} if($user[units] >= $attack[units]){ srand(time()); $random = (rand()%5)+1; echo "Well done you owned that NOOB!! "; $cashgain = floor($pot[cashpot] / $random); echo "You GAINED $cashgain gp"; $q = "UPDATE test SET money=money+'$cashgain', turns=turns-'1', wins=wins+'1' WHERE id='$user[id]'"; $r = mysqli_query($dbc, $q); $q = "INSERT INTO reports (id, username, message, outcome) VALUES ('$attack[id]', '$user[username]', 'The attacker Won and gained $cashgain gp','You lose')"; $r = mysqli_query($dbc, $q); }else{ echo "BETTER LUCK NEXT TIME YOU JUST GOT OWNED!!!"; $q = "UPDATE test SET turns=turns-'1', lose=lose+'1' WHERE id='$user[id]'"; $r = mysqli_query($dbc, $q); $q = "INSERT INTO reports (id, username, message, outcome) VALUES ('$attack[id]', '$user[username]', 'You Won','You Won')"; $r = mysqli_query($dbc, $q); } } ?> <table width="698" border="0" align="center"> <tr> <td width="279"><div align="center">Username</div></td> <td width="206"><div align="center">Alliance</div></td> <td width="55"><div align="center">Attack</div></td> <td width="68"><div align="center">Wins</div></td> <td width="68"><div align="center">Loses</div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/171533-solved-parse-error-parse-error-expecting-or-in-cxampphtdocsattackphp/ Share on other sites More sharing options...
AngelicS Posted August 23, 2009 Share Posted August 23, 2009 You have to add a backslash -> \ To all the quotation marks -> " inside the echo " "; Or else you close the echo. OR, you can use single quotation marks -> ' for the echo statement, like this echo ' '; But then you must wrap variables with these -> {} Quote Link to comment https://forums.phpfreaks.com/topic/171533-solved-parse-error-parse-error-expecting-or-in-cxampphtdocsattackphp/#findComment-904582 Share on other sites More sharing options...
wildteen88 Posted August 23, 2009 Share Posted August 23, 2009 You need to be escaping the double quotes (\") within this block of code. echo "<tr> <td width="279"><div align="center">$battle[username]</div></td> <td width="206"><div align="center">$battle[clan]</div></td> <td width="55"><div align="center"><a href=\"profile.php?profile=".$battle[username]."\">attack</a></div></td> <td width="68"><div align="center">$battle[wins]</div></td> <td width="68"><div align="center">$battle[lose]</div></td> </tr>"; Remember if you start your strings with a double quote. You must escape them within your string. Quote Link to comment https://forums.phpfreaks.com/topic/171533-solved-parse-error-parse-error-expecting-or-in-cxampphtdocsattackphp/#findComment-904584 Share on other sites More sharing options...
Danny620 Posted August 23, 2009 Author Share Posted August 23, 2009 wild do can you show me an example with my code please Quote Link to comment https://forums.phpfreaks.com/topic/171533-solved-parse-error-parse-error-expecting-or-in-cxampphtdocsattackphp/#findComment-904585 Share on other sites More sharing options...
phpretard Posted August 23, 2009 Share Posted August 23, 2009 echo " <tr> <td width=\"279\"><div align=\"center\">$battle[username]</div></td> <td width=\"206\"><div align=\"center\">$battle[clan]</div></td> <td width=\"55\"><div align=\"center\"> <a href=\"profile.php?profile=".$battle[username]."\">attack</a></div></td> <td width=\"68\"><div align=\"center\">$battle[wins]</div></td> <td width=\"68\"><div align=\"center\">$battle[lose]</div></td> </tr> "; Quote Link to comment https://forums.phpfreaks.com/topic/171533-solved-parse-error-parse-error-expecting-or-in-cxampphtdocsattackphp/#findComment-904586 Share on other sites More sharing options...
Danny620 Posted August 23, 2009 Author Share Posted August 23, 2009 thank so much Quote Link to comment https://forums.phpfreaks.com/topic/171533-solved-parse-error-parse-error-expecting-or-in-cxampphtdocsattackphp/#findComment-904591 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.