kncowans
(Getting the hang of it)
2003-06-20 11:49 AM
Urgent help required with DBGetRecordSet

Hello all

When I try to use the code listed below I get an 'Expected Expression' error on the DBGetRecordSet line.

Any help is appreciated.

Thanks in advance

Kevin

$dsn = "DRIVER=MySQL;SERVER=School;UID=root;PWD=;DATABASE=Internet"

$connection=DBConnOpen($dsn)

$YOI = SubStr( @UserID ,2 , 2)

$UserID = SubStr( @UserID , 4 , 4)

$recordset = DBGetRecordset($connection,"SELECT Internet FROM Access WHERE YOI='$YOI' AND USERID='$USERID'")

$retcode = DBConnClose($dsn)


Sealeopard
(KiX Master)
2003-06-20 05:42 PM
Re: Urgent help required with DBGetRecordSet

Check the returned error codes, as it is possible that the DBConnOpen did not suceed. Is a MySQL ODBC driver installed?

Also, rather use
code:
"SELECT Internet FROM Access WHERE YOI='"+$YOI+"' AND USERID='"+$USERID+"'"

as it is recommended to not have vars in strings.

Or try a simple SQL statement like "SELECT * FROM Access".

[ 22. June 2003, 22:36: Message edited by: sealeopard ]


kncowans
(Getting the hang of it)
2003-06-21 04:51 PM
Re: Urgent help required with DBGetRecordSet

Hello Sealeopard

Thanks for the reply.

I think your solution to do with the variables may fix the problem as when I replace the variables with fixed data the code works correctly.

Bye for now

Kevin


Sealeopard
(KiX Master)
2003-06-22 10:37 PM
Re: Urgent help required with DBGetRecordSet

SQL Statemenst are rather finicky with regards to the use of quotes. I always put a SQL statement into a variable before feeding it into the UDF.