I have an asp website, and i was using an MS Acess database, and i had to move to MySQL. I'm using a database converter, and some of the data shows, and other pulls up errors which im trying to resolve.
At the bottom is the full code of this page, but here is the part that seems to be causing the problem. - SELECT TOP 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = 3324 AND ID > 585 ORDER BY ID ASC
When i ran the above code in the MySQL query analayser this is the result: error 1064
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 '1 ID, `ID` FROM nm_tbl_comment WHERE fldNEWS_ID = 3324 AND ID > 585 ORDER BY ID' at line 1
So does anyone know what i need to do? how can i solve this problem? I'm prepared to change the method of importing data, but don't know how to do it. I used a database converter, as i thought it would be easy, but even the database converter cant convert some of code it seems
I am including all the relevant code in this page below, as it may be clearer to anyone who understands , what the problem may be. - <!--#include file="../config.asp"-->
-
-
<% Dim ID, RS, SQL, NAME, EMAIL, COMMENT, sDATE, IO, M_ID, SUBJECT, CITY, COUNTRY, ALLOW_E, AID, NEXT_ID, BACK_ID
-
-
ID = Trim(Request.QueryString("ID"))
-
AID = Trim(Request.QueryString("AID"))
-
IF IS_VALID_ID(ID) = False OR IS_VALID_ID(AID) = False THEN Response.END
-
IF Trim(Session("PMMS_IN")) = "True" THEN blLOGGED_IN = True
-
-
SQL = "SELECT fldNAME, fldEMAIL, fldCOMMENT, fldDATE, fldIP, fldM_ID, fldSUBJECT, fldCITY, fldCOUNTRY, fldALLOW FROM nm_tbl_comment WHERE ID = " & ID
-
Call OPEN_DB()
-
-
' Comment details
-
-
Set RS = Server.CreateObject("ADODB.Recordset")
-
RS.LockType = 1
-
RS.CursorType = 0
-
RS.Open SQL, MyConn
-
IF NOT RS.EOF THEN
-
NAME = trim(RS("fldNAME"))
-
EMAIL = trim(RS("fldEMAIL"))
-
COMMENT = trim(RS("fldCOMMENT")) & ""
-
sDATE = trim(RS("fldDATE"))
-
IP = trim(RS("fldIP"))
-
M_ID = trim(RS("fldM_ID"))
-
SUBJECT = trim(RS("fldSUBJECT"))
-
CITY = trim(RS("fldCITY"))
-
COUNTRY = trim(RS("fldCOUNTRY"))
-
ALLOW_E = trim(RS("fldALLOW"))
-
END IF
-
RS.Close
-
Set RS = Nothing
-
-
' Next Link
-
-
SQL = "SELECT TOP 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID > " & ID & " ORDER BY ID ASC"
-
Set RS = Server.CreateObject("ADODB.Recordset")
-
RS.Open SQL, MyConn
-
IF NOT RS.EOF THEN
-
NEXT_ID = trim(RS("ID"))
-
END IF
-
RS.Close
-
Set RS = Nothing
-
-
' Back Link
-
-
SQL = "SELECT TOP 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID < " & ID & " ORDER BY ID DESC"
-
Set RS = Server.CreateObject("ADODB.Recordset")
-
RS.Open SQL, MyConn
-
IF NOT RS.EOF THEN
-
BACK_ID = trim(RS("ID"))
-
END IF
-
RS.Close
-
Set RS = Nothing
-
-
MyConn.Close
-
Set MyConn = Nothing
-
-
-
-
%>
any help appreciated, thanks in advance
4 2297 Atli 5,058
Recognized Expert Expert
Hi.
It's the "TOP 1" part that is causing the problem. The TOP clause doesn't exist in MySQL. Use LIMIT instead.
For example, to get the first row in a table: - SELECT * FROM aTable LIMIT 1
The advantage of the LIMIT clause over TOP is that you can also specify an offset, like: - SELECT * aTable LIMIT 10, 1
Which would read one row, starting at row number 10.
Thank you for your reply, Atli
I tried changing the code in line 36 and 47 to: - SQL = "SELECT * FROM aTable LIMIT 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID > " & ID & " ORDER BY ID ASC"
however it didn't solve it,
This page is opened in a javascript pop up window as it is an article comment. It's actual calling page is another page (the news article). But i don't think that is of relevence or is it? i dont think i change to change the code in the article page do i?
On the news article page, this is the code that opens up the page whose code i posted above. It's opened up in a small javascript window. In the error message it says the error is actually in the comment page itself. But just in case, here is the code for the article page that opens the comment page: - <%
-
-
SQL = "SELECT ID, fldNAME, fldCOMMENT, fldDATE, fldSUBJECT, fldM_ID, fldCITY, fldCOUNTRY, fldALLOW, fldEMAIL FROM nm_tbl_comment WHERE fldNEWS_ID = " & NID & " ORDER BY ID ASC"
-
Set RS = Server.CreateObject("ADODB.Recordset")
-
RS.LockType = 1
-
RS.CursorType = 0
-
RS.Open SQL, MyConn
-
WHILE NOT RS.EOF
-
CCOUNT = CCOUNT + 1
-
C_ID = trim(RS("ID"))
-
C_NAME = trim(RS("fldNAME"))
-
C_COMMENT = trim(RS("fldCOMMENT"))
-
C_SUBJECT = trim(RS("fldSUBJECT"))
-
C_M_ID = trim(RS("fldM_ID"))
-
C_DATE = trim(RS("fldDATE"))
-
C_CITY = trim(RS("fldCITY"))
-
C_COUNTRY = trim(RS("fldCOUNTRY"))
-
C_ALLOW_E = trim(RS("fldALLOW"))
-
C_EMAIL = trim(RS("fldEMAIL"))
-
%>
Atli 5,058
Recognized Expert Expert
I tried changing the code in line 36 and 47 to: - SQL = "SELECT * FROM aTable LIMIT 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID > " & ID & " ORDER BY ID ASC"
however it didn't solve it,
Of course that didn't solve it. You have two FROM clauses in there, once of which refers to a table that I made up for my example!
You need to add the LIMIT clause to your old query, while removing the TOP clause.
The LIMIT clause needs to be the last thing in your query, like it was in my example query.
See the MySQL manual page on the SELECT statement to see exactly how it should be used.
Of course that didn't solve it. You have two FROM clauses in there, once of which refers to a table that I made up for my example!
You need to add the LIMIT clause to your old query, while removing the TOP clause.
The LIMIT clause needs to be the last thing in your query, like it was in my example query.
See the MySQL manual page on the SELECT statement to see exactly how it should be used.
Atli, thanks, that worked. Much appreciated.
I wonder if you or anyone else can see what is wrong with another similar problem i have. Again remember i migrated from Ms Access to MySql
This is an asp include page, and once again, it needs modifying somewhere, i'm not sure where.
It pulls up the latest 18 articles in a certain category, which are shown in a column, with a title, paragraph, image and link leading to the full news story.
The page doesn't return an error, it just doesn't show anything. ie no records are being pulled out of the database, or if they are, they aren't showing.
I'd appreciate it, if you or anyone could show me what i need to change here, i've copied and pasted, the code which i think is relevant below -
<% ' Dim SQL_SIDE, RS_SIDE, NID, TITLE, POSTED, NEWS_LISTING, SHOW_HL, MyConn_SIDE, I_SIDE, SUMMARY, CATE_ID, ANAME
-
-
-
-
-
' ------------------------------------------------------------------------------------------------------------------
-
-
' DATABASE CONNECTION
-
-
Set MyConn_SIDE = Server.CreateObject("ADODB.Connection")
-
-
MyConn_SIDE.Open "Driver={MySQL ODBC 3.51 Driver}; Server=987.564.300.77; uid=aname; pwd=mysql; database=title; option=3; port=3306;"
-
-
-
' NUMBER OF HEADLINES TO SHOW
-
-
SHOW_HL = 18
-
-
' Set to 1 if you are using MS Access, set to 2 if you are using MS SQL database
-
-
DB_TO_USE_CUSTOM = 3
-
-
' Category ID to pull the articles from
-
-
CATE_ID = "108"
-
-
' ------------------------------------------------------------------------------------------------------------------
-
-
-
-
-
-
-
-
SELECT CASE DB_TO_USE_CUSTOM
-
CASE 1
-
SQL_SIDE = "SELECT TOP " & SHOW_HL & " nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) AND nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CATE_ID & ") ORDER BY nm_tbl_news.ID DESC"
-
CASE 2
-
SQL_SIDE = "SELECT TOP " & SHOW_HL & " nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) AND nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CATE_ID & ") ORDER BY nm_tbl_news.ID DESC"
-
CASE 3
-
SQL_SIDE = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) AND nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CATE_ID & ") ORDER BY nm_tbl_news.ID DESC LIMIT " & SHOW_HL
-
END SELECT
-
-
-
I_SIDE = 0
-
Set RS_SIDE = Server.CreateObject("ADODB.Recordset")
-
RS_SIDE.LockType = 1
-
RS_SIDE.CursorType = 0
-
RS_SIDE.Open SQL_SIDE, MyConn_SIDE
-
WHILE NOT RS_SIDE.EOF
-
NID = trim(RS_SIDE("NID"))
-
TITLE = trim(RS_SIDE("TITLE"))
-
POSTED = trim(RS_SIDE("POSTED"))
-
SUMMARY = trim(RS_SIDE("fldSUMMARY"))
-
AUTHOR = trim(RS_SIDE("ANAME"))
-
IMAGE = trim(RS_SIDE("NIMAGE")) & ""
-
TITLE = PROCESS_SHORTCUTS_INC(False, TITLE)
-
SUMMARY = PROCESS_SHORTCUTS_INC(False, SUMMARY)
-
I_SIDE = I_SIDE + 1
-
IF I_SIDE =< SHOW_HL THEN
-
%>
-
-
-
-
-
<%IF NOT I_SIDE = SHOW_HL THEN%></div>
-
<hr align="JUSTIFY">
-
<div align="justify">
-
<%End If%>
-
-
-
<%
-
END IF
-
RS_SIDE.MoveNext
-
WEND
-
RS_SIDE.Close
-
Set RS_SIDE = Nothing
-
MyConn_SIDE.Close
-
Set MyConn_SIDE = Nothing
-
-
FUNCTION PROCESS_SHORTCUTS_INC(blOPEN, TEXT)
-
Dim SQL, RS, strRETURNED_DATA, EOF_VAL, intNUM_COL, intNUM_ROW, intROW_COUNTER, strSIGN, strIMAGE
-
SQL = "SELECT fldSIGN, fldIMAGE FROM nm_tbl_library WHERE fldACTIVE = 1"
-
Set RS = Server.CreateObject("ADODB.Recordset")
-
RS.LockType = 1
-
RS.CursorType = 0
-
RS.Open SQL, MyConn_SIDE
-
IF NOT RS.EOF THEN
-
strRETURNED_DATA = RS.getrows
-
ELSE
-
EOF_VAL = True
-
END IF
-
RS.close
-
Set RS = Nothing
-
IF Not EOF_VAL = True Then
-
intNUM_COL=ubound(strRETURNED_DATA,1)
-
intNUM_ROW=ubound(strRETURNED_DATA,2)
-
FOR intROW_COUNTER = 0 TO intNUM_ROW
-
strSIGN = Trim(strRETURNED_DATA(0,intROW_COUNTER))
-
strIMAGE = Trim(strRETURNED_DATA(1,intROW_COUNTER))
-
strIMAGE = "<img src='" & strIMAGE & "' border='0' alt='' />"
-
TEXT = Replace(TEXT, strSIGN, strIMAGE)
-
NEXT
-
END IF
-
PROCESS_SHORTCUTS_INC = TEXT
-
END FUNCTION
-
%>
by the way, do you know a good free database converter that will do the whole database? i'm using a trial version of one programme at the moment, which only pulls up a few records,
Many thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ryan Schefke |
last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
..I just sent this out to the win32 distribution list but no one has
replied.can someone on this list please help? The issue should be
trivial for experienced MySQL users, I'm just a novice, thanks!
|
by: Kevin Goad |
last post by:
Im running Mandrake Linux 9.1 on a Laptop I recently bought, and its
purpose its a PHP development machine, and I want to use a MySQL
Backend. I think when I was installing MySQL, something got corrupt,
and I cannot do anything, it says access denied(And no password was ever
set, and I've tried all the "--skip-grant-tables" and all that stuff).
Ive tried installing and uninstalling the RPM' packages, but a database
I created(called...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
|
by: MBR |
last post by:
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 19
Organization: Arcor
NNTP-Posting-Date: 02 Dec 2004 12:46:22 MET
NNTP-Posting-Host: a58bf304.newsread4.arcor-online.net
X-Trace: DXC=Gl27MQXTJCTD__2dTlB=EkaMXXY;eg@jLYe\NQ\`f2NU8P_mnR6@1cH6TQE]KL?G7HZePceTdIGCVST]
X-Complaints-To: abuse@arcor.de
Xref: number1.nntp.dca.giganews.com mailing.database.mysql-win32:6848 mailing.database.mysql:143134
|
by: chicha |
last post by:
Hey people,
I have to convert MS Access 2000 database into mysql database, the whole
thing being part of this project I'm doing for one of my faculty
classes. My professor somehow presumed I knew db's and gave me long list
of things to do with that particular database, first thing being that
particular conversion. Truth is that I don't know a first thing about
db's, let alone using mysql... I downloaded mysql form www.mysql.com and...
| |
by: Mell via AccessMonster.com |
last post by:
I created databases on Access 2003 and I want to deploy them to users. My
code was also done using 2003.
If they have Ms Access 2000 or higher, will they be able to use these dbs
with all code, etc?
Please explain
--
Message posted via http://www.accessmonster.com
|
by: NewbieSupreme |
last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x,
which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a
table to a text file, tab-delimited, text qualifyer of "none" (this is how I
read to do it from newsgroups).
When I use the Query window in phpmyadmin to import the text file, it waits
a while, then returns an error:
#1064 - You have an error in your SQL syntax; check the manual that...
|
by: blacksmoke |
last post by:
I got an error... when i wants to create database "usersinfo"
Username is 'blacksmoke'...
Commandline argumments are:
mysql> select user();
: e.g., blacksmoke@localhost
-------
|
by: Chad |
last post by:
Hi
Is it possible to substitute an alternative data source (eg MySQL or
SQL Server) into an existing MS-Access application?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |