Re: why do I get a syntax error? [message #180763 is a reply to message #180756] |
Sun, 17 March 2013 02:25 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 16/03/13 21:54, richard wrote:
> On Sat, 16 Mar 2013 17:32:00 -0400, richard wrote:
>
>> if (!$con) { die ("can not connect: " . mysql_error()};
>>
>> generates "Parse error: syntax error, unexpected '}' "
>> i have checked for matching brackets and other obvious syntax errors.
>
> Ok so here is the code I am using.
> I use Notepad++. It checks for matching brackets on the fly.
> If anything is not correct with the syntax, you will know their is a
> problem because the text colors change.
>
>
> $con = mysql_connect('localhost','user','pass');
>
>
> if (!$con){die("can not connect: " . mysql_error()};
Try ;} instead of };
>
> mysql_select_db('dbName',$con);
>
> $sql = "SELECT * FROM 1960";
Do you really have a table called '1960'?
> $myData=mysql_query($sql,$con);
> echo "<table border='1'>";
> echo
> "<tr><th>atitle</th><th>btitle</th><th>artist</th><th>label</th ></tr>";
>
> while ($record = mysql_fetch_array($myData)) {
> echo "<tr>";
> echo "<td>" . $record[atitle] . "</td>";
> echo "<td>" . $record[btitle] . "</td>";
> echo "<td>" . $record[artist] . "</td>";
> echo "<td>" . $record[label] . "</td>";
> echo "</tr>";
>
> };
Try } instead of };
>
> echo "</table";
>
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|