FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » why do I get a syntax error?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
why do I get a syntax error? [message #180753] Sat, 16 March 2013 21:32 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
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.
Re: why do I get a syntax error? [message #180754 is a reply to message #180753] Sat, 16 March 2013 21:46 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 16/03/13 21:32, 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.
>
obviously not hard enough..


--
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.
Re: why do I get a syntax error? [message #180755 is a reply to message #180753] Sat, 16 March 2013 21:47 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
richard <noreply(at)example(dot)com> wrote in news:whb767rvxtpg$.167pl8lnagxjt$.dlg@
40tude.net:

> 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.

Apparently your check for "other obvious syntax errors" did not include the obvious step of
ensuring that your parentheses match.
Re: why do I get a syntax error? [message #180756 is a reply to message #180753] Sat, 16 March 2013 21:54 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
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";
Re: why do I get a syntax error? [message #180757 is a reply to message #180753] Sat, 16 March 2013 22:31 Go to previous messageGo to next message
Ralf S. Hellersen is currently offline  Ralf S. Hellersen
Messages: 1
Registered: March 2013
Karma: 0
Junior Member
Am Sat, 16 Mar 2013 17:32:00 -0400 schrieb richard:

> 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.


There is a ")" missing:
if (!$con) { die ("can not connect: " . mysql_error())};

Regards
Ralf



--
Wegen SPAM: Für e-mail verwenden: "errr" statt "erxr" !
Re: why do I get a syntax error? [message #180758 is a reply to message #180756] Sat, 16 March 2013 22:42 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
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.
Re: why do I get a syntax error? [message #180759 is a reply to message #180753] Sat, 16 March 2013 22:44 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/16/2013 5:32 PM, 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.
>

Rewrite it with sensible formatting (as you should ALL your code):

if (!$con) {
die ("can not connect: " . mysql_error()
};

You're missing both a right paren and a semicolon.

And the semicolon AFTER the right brace is superfluous.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: why do I get a syntax error? [message #180761 is a reply to message #180759] Sat, 16 March 2013 23:29 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Sat, 16 Mar 2013 18:44:59 -0400, Jerry Stuckle wrote:

> On 3/16/2013 5:32 PM, 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.
>>
>
> Rewrite it with sensible formatting (as you should ALL your code):
>
> if (!$con) {
> die ("can not connect: " . mysql_error()
> };
>
> You're missing both a right paren and a semicolon.
>
> And the semicolon AFTER the right brace is superfluous.

thanks. fixed that.
it is odd that the video I copied the code from showed that ; after the
right brace.
anyways, the script is exactly what I need.
Re: why do I get a syntax error? [message #180763 is a reply to message #180756] Sun, 17 March 2013 02:25 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
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.
Re: why do I get a syntax error? [message #180764 is a reply to message #180756] Sun, 17 March 2013 02:49 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
richard the sto0pid wrote:

> richard the sto0pid wrote:
>
>> if (!$con) { die ("can not connect: " . mysql_error()};
>
> Ok so here is the code I am using.
> I use Notepad++. It checks for matching brackets on the fly.

If that is true, you should ask for your money back.

--
-bts
-This space for rent, but the price is high
Re: why do I get a syntax error? [message #180765 is a reply to message #180763] Sun, 17 March 2013 02:50 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
The Natural Philosopher wrote:

> richard the sto0pid wrote:
>> $sql = "SELECT * FROM 1960";
>
> Do you really have a table called '1960'?

Yes, RtS does. He's been dicking with this list of 1960 rock-n-roll songs
for about a decade now, and still hasn't been able to produce a worthwhile
page.

--
-bts
-This space for rent, but the price is high
Re: why do I get a syntax error? [message #180768 is a reply to message #180765] Sun, 17 March 2013 09:43 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 17/03/13 02:50, Beauregard T. Shagnasty wrote:
> The Natural Philosopher wrote:
>
>> richard the sto0pid wrote:
>>> $sql = "SELECT * FROM 1960";
>>
>> Do you really have a table called '1960'?
>
> Yes, RtS does. He's been dicking with this list of 1960 rock-n-roll songs
> for about a decade now, and still hasn't been able to produce a worthwhile
> page.
>
well yes. richard does seem to falsify the proposition that all men are
created equal.


--
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.
Re: why do I get a syntax error? [message #180771 is a reply to message #180768] Sun, 17 March 2013 14:04 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/17/2013 5:43 AM, The Natural Philosopher wrote:
> On 17/03/13 02:50, Beauregard T. Shagnasty wrote:
>> The Natural Philosopher wrote:
>>
>>> richard the sto0pid wrote:
>>>> $sql = "SELECT * FROM 1960";
>>>
>>> Do you really have a table called '1960'?
>>
>> Yes, RtS does. He's been dicking with this list of 1960 rock-n-roll songs
>> for about a decade now, and still hasn't been able to produce a
>> worthwhile
>> page.
>>
> well yes. richard does seem to falsify the proposition that all men are
> created equal.
>
>

Pot - Kettle - Black.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: change of color on a field value basis in a table...
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 19:17:53 GMT 2024

Total time taken to generate the page: 0.02374 seconds