473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Weird parse error

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
3 1471
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
"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
*** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta...
1
by: Manuel Maria Diaz Gomez | last post by:
Hi everybody, maybe you can give me a hint about the following problem: I have a simple template class that stores pointers to variables in a map, and publish the actual values when requested....
2
by: James Aguilar | last post by:
There is a syntax error in this code that I can't figure out. template <class T> std::ostream &operator <<(std::ostream &os, PriorityQueue<T> &q) { using namespace std; //g++ doesn't like...
8
by: Alan Little | last post by:
I started with the following code in an included file: $CompanyBlock = "$Company (Booth#: $Booth)\n". "$Address\n". "$City, $State $PostalCode\n". "$Website\n". "$Contact1, $Title1\n"....
5
by: Frances | last post by:
when I check my stylesheet in W3C checker get these errors: Line: 7 Context : ?? Parse Error - .info { width: 300; height: 160; overflow: auto; } Line: 9 Context : ?? Parse error -...
8
by: Rico | last post by:
Hello Everyone, I observed something strange in some quick testing code: void Button1Click(object sender, System.EventArgs e) { CultureInfo culture = new CultureInfo("th-TH", false); ...
2
by: sherifffruitfly | last post by:
Hi, I'm using an adaptation of excel-reading code that's all over the internet - I don't much like or understand it, but it has worked for me in the past.... beggars can't be choosers... : ...
0
by: rugman | last post by:
Hi. Let me immediately declare - I'm a designer/owner of a website written in jsp pages running under Apache Tomcat 5.5.25. I make simple changes to code but don't understand much about...
0
by: Rory McKinley | last post by:
Hi I am trying to use the TidyHTMLTreeBuilder module which is part of elementtidy, but I am getting what appears to be some sort of scope error and it is scrambling my n00b brain. The module...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.