Access to sql (1 Viewer)

rainman89

I cant find the any key..
Local time
Today, 10:47
Joined
Feb 12, 2007
Messages
3,015
Hi all,

I am writing php script to return the results from a query that I wrote in sql, but am getting the "too few parameters. expected 1" error.

The query runs fine in access, but in when I insert it into the php script to return the results, I get the error.

This is the code.

Code:
SELECT tblEmployee.EmployeeUserName, tblEmployee.EmployeeID, tblRequest.Approval, tblRequest.RequestDate
FROM tblEmployee INNER JOIN tblRequest ON tblEmployee.EmployeeID = tblRequest.EmployeeID
WHERE (((tblEmployee.EmployeeUserName)='$username'));

If i test it with only one table (tblEmployee), I get the results I am supposed to get, adding the 2nd table seems to mess it up.

Any help would be appreciated.
 

SOS

Registered Lunatic
Local time
Today, 07:47
Joined
Aug 27, 2008
Messages
3,517
Try changing this part:

WHERE (((tblEmployee.EmployeeUserName)='$username'));

to this:

WHERE (((tblEmployee.EmployeeUserName)=' & $username & '));
 

rainman89

I cant find the any key..
Local time
Today, 10:47
Joined
Feb 12, 2007
Messages
3,015
Try changing this part:

WHERE (((tblEmployee.EmployeeUserName)='$username'));

to this:

WHERE (((tblEmployee.EmployeeUserName)=' & $username & '));

Thanks SOS. No go.

I thought perhaps it had something to do with the where clause also, but if i remove it completely, I still get the error.

Its not making much sense to me. I had it working yesterday and removed one lookup table from the databse and all of the sudden, I can't get it to work at all.
 

rainman89

I cant find the any key..
Local time
Today, 10:47
Joined
Feb 12, 2007
Messages
3,015
AGHHHHH!!!

I was running the query in my test database where i added the tblRequest.approval field, but in my actual database, I didn't have that in the table....

Query works fine as is, im just an idiot and forgot to add the field to the table!!

Thanks SOS
 

SOS

Registered Lunatic
Local time
Today, 07:47
Joined
Aug 27, 2008
Messages
3,517
I don't see anything else, if that is the whole query. Perhaps putting the field names in square brackets would help but I don't see anything that might be construed as a reserved word unless RequestDate is in PHP (which I don't know PHP so I'm no help there).
 

SOS

Registered Lunatic
Local time
Today, 07:47
Joined
Aug 27, 2008
Messages
3,517
AGHHHHH!!!

I was running the query in my test database where i added the tblRequest.approval field, but in my actual database, I didn't have that in the table....

Query works fine as is, im just an idiot and forgot to add the field to the table!!

Thanks SOS

Ah, yes that would do it. :D Glad you figured it out as it was a bit strange. :)
 

Users who are viewing this thread

Top Bottom