By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

Weird parse error

P: n/a
The following code produces a parse error:

$res=mysql_query($sql) or return('There was an error');

However, this works fine:

$res=mysql_query($sql) or die('There was an error');

I can't understand why. In case of SQL error I only want to stop executing
current function, not the whole script.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
if(!$res=mysql_query($sql)) return("There was an error");

Denada,

Michel

"Alvaro G Vicario" <al******************@telecomputeronline.com> wrote in
message news:l6****************************@40tude.net...
The following code produces a parse error:

$res=mysql_query($sql) or return('There was an error');

However, this works fine:

$res=mysql_query($sql) or die('There was an error');

I can't understand why. In case of SQL error I only want to stop executing
current function, not the whole script.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--

Jul 17 '05 #2

P: n/a
"Alvaro G Vicario" <al******************@telecomputeronline.com> wrote in
message news:l6****************************@40tude.net...
The following code produces a parse error:

$res=mysql_query($sql) or return('There was an error');

However, this works fine:

$res=mysql_query($sql) or die('There was an error');

I can't understand why. In case of SQL error I only want to stop executing
current function, not the whole script.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--


return is a operator, that's why. Same thing would happen if you do " ... or
echo $error."
Jul 17 '05 #3

P: n/a
*** Chung Leong wrote/escribió (Tue, 15 Jun 2004 18:07:32 -0400):
return is a operator, that's why. Same thing would happen if you do " ... or
echo $error."


You are right: it happens with echo, exit... I didn't have the faintest
idea that you couldn't use them this way.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.