|  | Posted by Tim Streater on 06/13/27 11:27 
In article <Op-dndHn_I3w-67eRVn-gw@rogers.com>,"Joseph Melnick" <jmelnick@jphp.com> wrote:
 
 > Plato wrote:
 > "plato" <platoTAKETHISOUT@telpacific.com.au> wrote in message
 > news:43329cd6@news.rivernet.com.au...
 > >
 > > "Tim Streater" <tim.streater@dante.org.uk> wrote in message
 > > news:tim.streater-3C69F9.12100522092005@individual.net...
 > >> In article <433287e7@news.rivernet.com.au>,
 > >>  "plato" <platoTAKETHISOUT@telpacific.com.au> wrote:
 > >>
 > >>
 > >> [trillions of copies of unnecessary stuff deleted]
 > >>
 > >> > I followed your advice and have created the table :courses and inserted
 > > 2
 > >> > fields course and places and populated them with course 1 and 11 places
 > >> > (integer) and course 2 and 15 places (integer) running this script:
 > >> >
 > >> > <?PHP
 > >> >
 > >> > //alter you variables here
 > >> > $host = "localhost";
 > >> > $username="";
 > >> > $password="";
 > >> > $database="paul";
 > >> >
 > >> > // create link to database
 > >> > $link = mysql_connect($host, $username, $password)
 > >> >      or die("Cannot connect to database");
 > >> >
 > >> > mysql_select_db($database)
 > >> >      or die("Cannot select database");
 > >> >
 > >> > //now we make the query which will ask the database for the course
 > >> > information
 > >> > //change the my_table to your course table name
 > >> >
 > >> > $query = "SELECT course,places FROM courses";
 > >> > $result = mysql_query($query)
 > >> >      or die("Query cannot be executed");
 > >> >
 > >> > //now we are going to print the information to your screen
 > >> > while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
 > >> >        printf ("course: %s  places: %s<br>", $row['course'],
 > >> > $row['places']);
 > >> > }
 > >> > ?>
 > >> >
 > >> > Still getting this error:
 > >> >
 > >> > Parse error: syntax error, unexpected T_VARIABLE in
 > > c:\wamp\www\Untitled.php
 > >> > on line 20
 > >> >
 > >> > but I can't see anything wrong with that line??
 > >>
 > >> There's nothing wrong syntactically with line 20. Its line 17 that's the
 > >> problem. What's PHP supposed to do with the word "information" sitting
 > >> there all by itself?
 > >>
 > >> -- tim
 > >
 > > You're a bloody genius Tim thanks
 > >
 > >
 > Yes Tim,
 >
 > Good eye. It is always a good idea to wrap comments like so:  /* My Comment
 > */ certainly // My Comment is valid
 > but breaks when words you intend to be a part of the comment flow to the
 > next line ie when you accidently hit the return key and keep typing.
 >
 > It is definately good form to comment your code.
 > Even better when comments do not cause bugs :)
 
 Hmmm, I can't be arsed to use the /* */ construct, all my comments are
 of the // variety. I am just used to the fact that languages of this
 type have problems reporting errors accurately (perhaps because it's
 parsed in a single pass? I don't know. Note that it gives up at the
 first error). In some cases the error can be hundreds of lines away,
 although in a case like this I would say the code needs restructuring as
 well as simply fixing.
 
 If the offending line looks OK, make a copy of your program file and
 start removing chunks until PHP doesn't complain ay more. This may help
 pin down the problem. Bit of a brute force approach perhaps but
 necessary sometimes.
 
 -- tim
  Navigation: [Reply to this message] |