Syntax frustration

This is a discussion on Syntax frustration within the MySQL Database forums, part of the Database Forums category; I'm getting a syntax complaint with the following query SELECT documents.DocPassportFirstName, documents.DocPassportFamilyName, countries.ConNationality, documents.DocPassportNo, documents....


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-31-2007
Dan
 
Posts: n/a
Default Syntax frustration

I'm getting a syntax complaint with the following query

SELECT documents.DocPassportFirstName,
documents.DocPassportFamilyName,
countries.ConNationality,
documents.DocPassportNo,
documents.DocPassportIssueDate,
documents.DocPassportPlaceOfIssue,
documents.DocPassportExpiryDate,
documents.DocDLFirstName,
documents.DocDLFamalyName,
documents.DocDLNationality,
documents.DocDLNo,
documents.DocBdcWith,
documents.DocBdcPolNo,
documents.DocBdcTelNo,
documents.DocBdcExpiryDate,
documents.DocMOTDue,
documents.DocCCP,
documents.DocCCPPolNo,
documents.DocCCPTelNo,
documents.DocUpDate
FROM documents, countries
WHERE documents.DocPassportNationalty = countries.ConID
AND MemberID = $memberid;

MySQL Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near '' at line 1

I can't see what is wrong with it! Can anyone else see my mistake?

Reply With Quote
  #2 (permalink)  
Old 01-31-2007
strawberry
 
Posts: n/a
Default Re: Syntax frustration

On 31 Jan, 14:06, "Dan" <dp_pea...@hotmail.com> wrote:
> I'm getting a syntax complaint with the following query
>
> SELECT documents.DocPassportFirstName,
> documents.DocPassportFamilyName,
> countries.ConNationality,
> documents.DocPassportNo,
> documents.DocPassportIssueDate,
> documents.DocPassportPlaceOfIssue,
> documents.DocPassportExpiryDate,
> documents.DocDLFirstName,
> documents.DocDLFamalyName,
> documents.DocDLNationality,
> documents.DocDLNo,
> documents.DocBdcWith,
> documents.DocBdcPolNo,
> documents.DocBdcTelNo,
> documents.DocBdcExpiryDate,
> documents.DocMOTDue,
> documents.DocCCP,
> documents.DocCCPPolNo,
> documents.DocCCPTelNo,
> documents.DocUpDate
> FROM documents, countries
> WHERE documents.DocPassportNationalty = countries.ConID
> AND MemberID = $memberid;
>
> MySQL Error: You have an error in your SQL syntax; check the manual
> that corresponds to your MySQL server version for the right syntax to
> use near '' at line 1
>
> I can't see what is wrong with it! Can anyone else see my mistake?


try echoing the query

Reply With Quote
  #3 (permalink)  
Old 01-31-2007
Dan
 
Posts: n/a
Default Re: Syntax frustration

> try echoing the query

I have and I can't spot the error :¬(


Reply With Quote
  #4 (permalink)  
Old 01-31-2007
Captain Paralytic
 
Posts: n/a
Default Re: Syntax frustration

On 31 Jan, 14:06, "Dan" <dp_pea...@hotmail.com> wrote:
> I'm getting a syntax complaint with the following query
>
> SELECT documents.DocPassportFirstName,
> documents.DocPassportFamilyName,
> countries.ConNationality,
> documents.DocPassportNo,
> documents.DocPassportIssueDate,
> documents.DocPassportPlaceOfIssue,
> documents.DocPassportExpiryDate,
> documents.DocDLFirstName,
> documents.DocDLFamalyName,
> documents.DocDLNationality,
> documents.DocDLNo,
> documents.DocBdcWith,
> documents.DocBdcPolNo,
> documents.DocBdcTelNo,
> documents.DocBdcExpiryDate,
> documents.DocMOTDue,
> documents.DocCCP,
> documents.DocCCPPolNo,
> documents.DocCCPTelNo,
> documents.DocUpDate
> FROM documents, countries
> WHERE documents.DocPassportNationalty = countries.ConID
> AND MemberID = $memberid;
>
> MySQL Error: You have an error in your SQL syntax; check the manual
> that corresponds to your MySQL server version for the right syntax to
> use near '' at line 1
>
> I can't see what is wrong with it! Can anyone else see my mistake?


I tried pasting it into phpMyAdmin and all it said to me was that the
tables didn't exist. No SQL error was posted.

Reply With Quote
  #5 (permalink)  
Old 01-31-2007
strawberry
 
Posts: n/a
Default Re: Syntax frustration

On Jan 31, 3:30 pm, "Captain Paralytic" <paul_laut...@yahoo.com>
wrote:
> On 31 Jan, 14:06, "Dan" <dp_pea...@hotmail.com> wrote:
>
>
>
> > I'm getting a syntax complaint with the following query

>
> > SELECT documents.DocPassportFirstName,
> > documents.DocPassportFamilyName,
> > countries.ConNationality,
> > documents.DocPassportNo,
> > documents.DocPassportIssueDate,
> > documents.DocPassportPlaceOfIssue,
> > documents.DocPassportExpiryDate,
> > documents.DocDLFirstName,
> > documents.DocDLFamalyName,
> > documents.DocDLNationality,
> > documents.DocDLNo,
> > documents.DocBdcWith,
> > documents.DocBdcPolNo,
> > documents.DocBdcTelNo,
> > documents.DocBdcExpiryDate,
> > documents.DocMOTDue,
> > documents.DocCCP,
> > documents.DocCCPPolNo,
> > documents.DocCCPTelNo,
> > documents.DocUpDate
> > FROM documents, countries
> > WHERE documents.DocPassportNationalty = countries.ConID
> > AND MemberID = $memberid;

>
> > MySQL Error: You have an error in your SQL syntax; check the manual
> > that corresponds to your MySQL server version for the right syntax to
> > use near '' at line 1

>
> > I can't see what is wrong with it! Can anyone else see my mistake?

>
> I tried pasting it into phpMyAdmin and all it said to me was that the
> tables didn't exist. No SQL error was posted.


I suspect the error is in the contents of $memberid - but without
seeing the echoed query it's difficult to tell.

Reply With Quote
  #6 (permalink)  
Old 01-31-2007
Sanders Kaufman
 
Posts: n/a
Default Re: Syntax frustration

Jerry Gitomer wrote:

>> WHERE documents.DocPassportNationalty = countries.ConID
>> AND MemberID = $memberid;
>>
>> MySQL Error: You have an error in your SQL syntax; check the manual
>> that corresponds to your MySQL server version for the right syntax to
>> use near '' at line 1
>>
>> I can't see what is wrong with it! Can anyone else see my mistake?
>>

> Two suggestions. First, try putting $memberid in quotes. Second, verify
> the spelling of each of your column names.


No - don't do that.
Numbers should not be enclosed in quotes.
Reply With Quote
  #7 (permalink)  
Old 02-01-2007
Jerry Gitomer
 
Posts: n/a
Default Re: Syntax frustration

Dan wrote:
> I'm getting a syntax complaint with the following query
>
> SELECT documents.DocPassportFirstName,
> documents.DocPassportFamilyName,
> countries.ConNationality,
> documents.DocPassportNo,
> documents.DocPassportIssueDate,
> documents.DocPassportPlaceOfIssue,
> documents.DocPassportExpiryDate,
> documents.DocDLFirstName,
> documents.DocDLFamalyName,
> documents.DocDLNationality,
> documents.DocDLNo,
> documents.DocBdcWith,
> documents.DocBdcPolNo,
> documents.DocBdcTelNo,
> documents.DocBdcExpiryDate,
> documents.DocMOTDue,
> documents.DocCCP,
> documents.DocCCPPolNo,
> documents.DocCCPTelNo,
> documents.DocUpDate
> FROM documents, countries
> WHERE documents.DocPassportNationalty = countries.ConID
> AND MemberID = $memberid;
>
> MySQL Error: You have an error in your SQL syntax; check the manual
> that corresponds to your MySQL server version for the right syntax to
> use near '' at line 1
>
> I can't see what is wrong with it! Can anyone else see my mistake?
>

Two suggestions. First, try putting $memberid in quotes.
Second, verify the spelling of each of your column names.

HTH

Jerry

Reply With Quote
  #8 (permalink)  
Old 02-01-2007
Sanders Kaufman
 
Posts: n/a
Default Re: Syntax frustration

strawberry wrote:
> On Jan 31, 11:50 pm, Sanders Kaufman <b...@kaufman.net> wrote:
>> Jerry Gitomer wrote:


>>>> WHERE documents.DocPassportNationalty = countries.ConID
>>>> AND MemberID = $memberid;


>>>> MySQL Error: You have an error in your SQL syntax; check the manual
>>>> that corresponds to your MySQL server version for the right syntax to
>>>> use near '' at line 1


>> No - don't do that.
>> Numbers should not be enclosed in quotes.

>
> you don't know that it's a number


I don't know that the sun will rise tomorrow, either, but I'll
bet you a PayPal dollar on it.

For one thing - the error that came back wasn't bitching about
that particular problem. There's a different error that comes
back for cast problems like that.

This one is a *syntax* error. That means that somewhere there's
a misspled word, an out-of-place comma, or an unclosed quote,
comma or parenthesis.

For another thing - ID's are like *always* numbers. Using the
AUTO_NUMBER feature to create PK's named "id" is just too THE
way to do it. If somebody does PK's in MySQL any other way -
I'd always suggest they do it this way, instead.

Indeed using that kind of PK instead of some string is probably
the easiest way to speed up queries and such - because numbers
are sooo NOT resource intensive to index.










Reply With Quote
  #9 (permalink)  
Old 02-01-2007
strawberry
 
Posts: n/a
Default Re: Syntax frustration

On Jan 31, 11:50 pm, Sanders Kaufman <b...@kaufman.net> wrote:
> Jerry Gitomer wrote:
> >> WHERE documents.DocPassportNationalty = countries.ConID
> >> AND MemberID = $memberid;

>
> >> MySQL Error: You have an error in your SQL syntax; check the manual
> >> that corresponds to your MySQL server version for the right syntax to
> >> use near '' at line 1

>
> >> I can't see what is wrong with it! Can anyone else see my mistake?

>
> > Two suggestions. First, try putting $memberid in quotes. Second, verify
> > the spelling of each of your column names.

>
> No - don't do that.
> Numbers should not be enclosed in quotes.


you don't know that it's a number

Reply With Quote
  #10 (permalink)  
Old 02-01-2007
Cr♥sby
 
Posts: n/a
Default Re: Syntax frustration

Dan wrote:
> I'm getting a syntax complaint with the following query
>
> SELECT documents.DocPassportFirstName,
> documents.DocPassportFamilyName,
> countries.ConNationality,
> documents.DocPassportNo,
> documents.DocPassportIssueDate,
> documents.DocPassportPlaceOfIssue,
> documents.DocPassportExpiryDate,
> documents.DocDLFirstName,
> documents.DocDLFamalyName,
> documents.DocDLNationality,
> documents.DocDLNo,
> documents.DocBdcWith,
> documents.DocBdcPolNo,
> documents.DocBdcTelNo,
> documents.DocBdcExpiryDate,
> documents.DocMOTDue,
> documents.DocCCP,
> documents.DocCCPPolNo,
> documents.DocCCPTelNo,
> documents.DocUpDate
> FROM documents, countries
> WHERE documents.DocPassportNationalty = countries.ConID
> AND MemberID = $memberid;
>
> MySQL Error: You have an error in your SQL syntax; check the manual
> that corresponds to your MySQL server version for the right syntax to
> use near '' at line 1
>
> I can't see what is wrong with it! Can anyone else see my mistake?
>

Is MemberID a field in documents or in countries table?
I say near to near '' that's sign that $memberid is NULL
and then you should use NULL in Field description and you didn't
or some other thing

show us more code
and the table definition


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:20 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0