puggo Posted September 4, 2007 Share Posted September 4, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/67893-t_constant_encapsed_string/ Share on other sites More sharing options...
sasa Posted September 4, 2007 Share Posted September 4, 2007 change <?include("conninfo.php")?> to <?php include("conninfo.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/67893-t_constant_encapsed_string/#findComment-341253 Share on other sites More sharing options...
puggo Posted September 4, 2007 Author Share Posted September 4, 2007 still get same the errors ??? Quote Link to comment https://forums.phpfreaks.com/topic/67893-t_constant_encapsed_string/#findComment-341255 Share on other sites More sharing options...
puggo Posted September 4, 2007 Author Share Posted September 4, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/67893-t_constant_encapsed_string/#findComment-341272 Share on other sites More sharing options...
sasa Posted September 4, 2007 Share Posted September 4, 2007 change to $query=mysql_query( "INSERT INTO basket (ProductID, ProductPrice, ProductName) VALUES ('$id','$price','$name')") or die("couldnt"); Quote Link to comment https://forums.phpfreaks.com/topic/67893-t_constant_encapsed_string/#findComment-341274 Share on other sites More sharing options...
puggo Posted September 4, 2007 Author Share Posted September 4, 2007 thanks sasa, now the page willl load but i get the "couldnt" message and it wont add to my database, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/67893-t_constant_encapsed_string/#findComment-341276 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.