slj90 Posted January 15, 2010 Share Posted January 15, 2010 <?php if ($row["Money"] > '800') echo "<a href="http://localhost/burned/buypistol.php?ID=<?php echo $row["ID"]?>"> Buy </a>" if ($row["Money"] < '800') echo "You cannot afford this item"; ?> The line that's not working is: echo "<a href="http://localhost/burned/buypistol.php?ID=<?php echo $row["ID"]?>"> Buy </a>" Thanks for your help Link to comment https://forums.phpfreaks.com/topic/188565-why-is-this-simple-code-not-working-urgent/ Share on other sites More sharing options...
JamesThePanda Posted January 15, 2010 Share Posted January 15, 2010 try echo '"<a href="http://localhost/burned/buypistol.php?ID=<?php echo $row["ID"]?>"> Buy </a>" ' You appear to misses the single qutes and a semi colon give that a try and letme know Thanks James Link to comment https://forums.phpfreaks.com/topic/188565-why-is-this-simple-code-not-working-urgent/#findComment-995521 Share on other sites More sharing options...
trq Posted January 15, 2010 Share Posted January 15, 2010 Take a look at it. You have double quotes within a double quoted string. PHP thinks your ending the string prematurely. You need to escape the inner quotes. You also open a new php block within an already existing piece of php code. Your also missing the closing ; echo "<a href=\"http://localhost/burned/buypistol.php?ID={$row['ID']}\"> Buy </a>"; You may want to invest in a decent editor with syntax highlighting. Netbeans is free, and highly recommended. Link to comment https://forums.phpfreaks.com/topic/188565-why-is-this-simple-code-not-working-urgent/#findComment-995522 Share on other sites More sharing options...
oni-kun Posted January 15, 2010 Share Posted January 15, 2010 You're placing PHP delimiter tags within eachother. <?php if ($row["Money"] > '800') { echo "<a href='http://localhost/burned/buypistol.php?ID=" . $row["ID"] . "'> Buy </a>"; } else if ($row["Money"] < '800') { echo "You cannot afford this item"; } ?> Link to comment https://forums.phpfreaks.com/topic/188565-why-is-this-simple-code-not-working-urgent/#findComment-995524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.