Jump to content

T_CONSTANT_ENCAPSED_STRING


puggo

Recommended Posts

I really cannot get to grips with this why it isnt working, once i get something finally workking i get other errors.

 

Here is my code:

 

<?include("conninfo.php")?>
<?php
session_start(); 
?>
<html>
<head>
<title>The Music Shop</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
  <div id="header"><h1><img src="Images/banner.jpg"</h1>

</div>


<div id = "top_nav">
  <a href="index.html">Home</a><span class="invisible"> | </span>
    <a href="register.php">Register</a><span class="invisible"> | </span>
	<a href="account.php">Login</a><span class="invisible"> | </span>
	<a href="products.php">Products</a><span class="invisible"> | </span>
	<a href="search.php">Search</a><span class="invisible"> | </span>
	<a href="cart.php">Shopping Basket|</a>

</div>

<?
$id=$_POST["ProductID"];
$price=$_POST["ProductPrice"];
$name=$_POST["ProductName"];
?>

<?

$query=mysql_query("INSERT INTO basket(ProductID,ProductPrice,ProductName) 
VALUES("'$id','$price','$name'" or die("couldn't");

?>
Go to Basket:

</body>
</html>

 

<?include("conninfo.php")?>
<?php
session_start(); 
?>
<html>
<head>
<title>The Music Shop</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
  <div id="header"><h1><img src="Images/banner.jpg"</h1>

</div>


<div id = "top_nav">
  <a href="index.html">Home</a><span class="invisible"> | </span>
    <a href="register.php">Register</a><span class="invisible"> | </span>
	<a href="account.php">Login</a><span class="invisible"> | </span>
	<a href="products.php">Products</a><span class="invisible"> | </span>
	<a href="search.php">Search</a><span class="invisible"> | </span>
	<a href="cart.php">Shopping Basket|</a>

</div>
<?

	$query="SELECT * FROM products ";
	$result=mysql_query($query) or die("Couldnt do it");?>
	<?$numrows=mysql_num_rows($result);
	if ($numrows>0)
	{?>
	 <table border="1">
	 	<?			
	 while($r=mysql_fetch_array($result))
      {?>
		<form action="cart.php" method="post">
      <tr>
		<td><?echo $r["ProductID"];?></td>
      <td><?echo $r["ProductPrice"];?></td>
		<td><?echo $r["ProductName"];?></td>
		<td><img src="images/<?echo $r["Preview"];?>" alt="Image"></td>
		<td><input type="hidden" name="ProductID" id="ProductID" value=<? echo $r['ProductID'];?>/></td>
		<td><input type="hidden" name="ProductPrice" id="ProductPrice" value=<? echo $r['ProductPrice'];?>/></td>
		<td><input type="hidden" name="ProductName" id="ProductName" value=<? echo $r['ProductName'];?>/></td>
		<td><input type="submit" value="Add to basket"></td>
      </form>

	 </td>
		</tr>
		<?
      }
      ?>
      </table>



<?}
else
{
echo("Nothing Found.");
}

 

This is the error i recieve:

 

 

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in d:\inetpub\wwwroot\SimonJenkins\Assignment\cart.php on line 35

 

Link to comment
Share on other sites

ok so now ive rewritten the insert into code which is now

 

$query=mysql_query "INSERT INTO basket (ProductID, ProductPrice, ProductName) VALUES ('$id','$price','$name')"; or die("couldnt");

 

but now im getting this error:

 

 

Parse error: parse error, unexpected '"' in d:\inetpub\wwwroot\SimonJenkins\Assignment\cart.php on line 34

 

ive checked it about 20 times, taken things out, added things back but i still get this error.

 

Please help!

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.