|
Posted by Joseph Melnick on 10/13/25 11:27
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 :)
Joseph Melnick
JM Web Consultants
Toronto ON Canada
[Back to original message]
|