Re: why do I get a syntax error? [message #180758 is a reply to message #180756] |
Sat, 16 March 2013 22:42 |
|
richard
Messages: 213 Registered: June 2013
Karma:
|
Senior Member |
|
|
On Sat, 16 Mar 2013 17:54:53 -0400, 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())};
>
> mysql_select_db('dbName',$con);
>
> $sql = "SELECT * FROM 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>";
>
> };
>
> echo "</table";
I noticed I was missing a ) in that line.
so I corrected it here but still get the error.
|
|
|