View Full Version : Access to sql


rainman89
02-25-2010, 10:51 AM
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.


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
02-25-2010, 11:25 AM
Try changing this part:

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

to this:

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

rainman89
02-25-2010, 11:29 AM
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
02-25-2010, 11:34 AM
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
02-25-2010, 11:34 AM
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
02-25-2010, 11:35 AM
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. :)