Jump to content

Why is this simple code not working? *urgent*


slj90

Recommended Posts

<?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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.