Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FROM Syntax error

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
0
0
US
Hi guys, i'm reading Ben Forta's book Cold Fusion Web Database Construction Kit. So i'm using microsoft query to practice inserting tables and such. but everytime i try to so a select to read from a table i get an error saying "syntax error in from clause" here's an example of the code that produces the error.

SELECT
LEFT(FirstName, 1)+LastName+'@a2zbooks.com'
FROM Employees

it does it on any select statement with a from clause in it. any ideas? Thanks in advance.
 
Wow even more stuff.. I uninstalled CF studio 4.5.2 and reinstalled 4.5.1.. i've written a simple cfm (from forta's book)

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Hello</title>
</head>

<body>
<CFOUTPUT>
Hello,<BR>
Your IP Address is :<b>#REMOTE_ADDR#</b>
Your Browser is :<b>#TAG_USER_AGENT#</b><p>
</CFOUTPUT>

</body>
</html>

And now i'm getting this error..

Error Occurred While Processing Request
Error Diagnostic Information
An error has occurred.


HTTP/1.0 404 Object Not Found

I REALLY want to learn CF, but this is kinda annoying.. am i doing something wrong?

 
The problem stays in the semantic of your query.
Within a SELECT statement you select a column of a certain content, not the content itself.
I suppose that you're confusing the semantic: you confuse the WHERE clause with the EMAIL column name.
If I understand correclty your problem, you're probable trying to select some employee which name is LASTNAME, FIRSTNAME depending upon the content of the EMAIL field.

So the solution of your problem, probably, should be like this:

<CFOUTPUT>
<CFSET Wanted = &quot;#left(FirstName, 1)##LastName#@a2zbooks.com&quot;>
<CFQUERY NAME=&quot;FindEmployee&quot; etc. etc. >
SELECT * FROM Employees
WHERE EMAIL = '#Wanted#'
</CFQUERY>
</CFOUTPUT>

Notice that it's easier and faster to make CF to compose the string using a CFOUTPUT statement, simply putting many #..# one at the other's side.


 
Hi,

Try this for your first question:

Code:
<cfset email = LEFT(FirstName, 1) & LastName & '@a2zbooks.com'>
SELECT * FROM Employees
where email = '#email#'

(SerbonF, you beat me to this one :) )

And this for your second:

Code:
<CFOUTPUT>
Hello,<BR>
Your IP Address is :<b>#REMOTE_ADDR#</b>
Your Browser is :<b>#HTTP_USER_AGENT#</b><p>
</CFOUTPUT>

Hope this gets you further? :p

Gtz,

Kristof
 
hi gmagerr

HTTP/1.0 404 Object Not Found

That is an error from the web server telling you it could not locate any file with the location you specified. Make sure that your CFM file is within the inetpub directory or wherever your web servers root is.

---
keep reading, it prevents assumptions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top