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

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.

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";
}
  ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.