Jump to content

Help, Can't find the Error?


joebgiddings

Recommended Posts

Hello,

First time i'm using PHP for a project at uni, we have been given some examples to work from, however i keep getting an error and i can't see what the problem is?

this is the error

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\ebassignment\purchases1.php on line 24

and this is the code its refering to:

<html>
<head> <title>Buyer </title> </head>
<body>
<h2> You chose</h2>
<table>   
<?php
    $myFile = "(path)purchases.dat";
    $fh = fopen($myFile, 'a') or die("can't open file\n");
    $total=0;
    if (!($lines = file('items.txt')))
{echo 'ERROR: Unable to open file! </body></html>'; exit;}
    // assumes POST as method - see note below
    foreach ($_POST as $varname => $varvalue) {
        foreach($lines as $theline) {
list($ISBN, $title, $author, $price_inc_vat, $price_ex_vat, $image, $qty) = split('\|', $theline);   
        if ($ISBN==$varname) {
//print out the line to browser

echo " <tr>
            <td><img src='$image' ></td>
          <td> $author </td> <td> $price_inc_vat GBP </td> </tr>";
$total=$total+$price_inc_vat;
//create an entry for append-write to file
          $content = $cust_num .'|'. $ISBN '\n';
          if (!(fwrite($fh , $content)))
              { echo "Cannot write to ($myFile)\n</p>";  exit; }
    }
}  }  
// ending the 'foreach' loops
echo "  <tr>    <td> </td>
--------------

this being line 24

$content = $cust_num .'|'. $ISBN '\n';

Any help would be great

Joe
Link to comment
https://forums.phpfreaks.com/topic/27871-help-cant-find-the-error/
Share on other sites

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.