Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange PHP /MYSQL Error

Status
Not open for further replies.

Grumm

Technical User
Sep 27, 2002
68
0
0
AU
I have a strange problem where my code works on my hosted domain but not on my local machine and I cannot figure out why? It must be in the PHP.ini or my.ini files.

This is the script that works on the domain but not on my local machine: -

//Open Method @260-9D834628
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect");
$this->CountSQL = "SELECT COUNT(*) FROM Employees_Certs " .
"LEFT JOIN Suppliers ON Employees_Certs.SupplierID = Suppliers.SupplierID " .
"WHERE Employees_Certs.EmployeeID = " . $this->SQLValue($this->wp->GetDBValue("1"), ccsInteger) . " " .
"AND Suppliers.CompanyID = " . $this->SQLValue($this->wp->GetDBValue("2"), ccsInteger) . " " .
"";

This code produces the following SQL Error in my local machine but works on my host.

Database error: Invalid SQL: SELECT COUNT(*) FROM Employees_Certs LEFT JOIN Suppliers ON Employees_Certs.SupplierID = Suppliers.SupplierID WHERE Employees_Certs.EmployeeID = AND Suppliers.CompanyID = 1
MySQL Error: 1064 (You have an error in your SQL syntax near 'AND Suppliers.CompanyID = 1 ' at line 1)
Session halted.

Can anyone suggest where I may have some settings different.

Regards
 
[tt] WHERE Employees_Certs.[red]EmployeeID = AND [red]Suppliers.CompanyID = 1 [/tt]

where EmployeeID is = to what??

Cheers.
 
[tt] WHERE Employees_Certs.[red]EmployeeID = AND [/red]Suppliers.CompanyID = 1 [/tt]

Again, to show in red as I wanted...
where EmployeeID is = to what??

Cheers.
 
I am quite new to mysql and PHP so sorry if this is not clear.

The employeeID is passed from another form any could have a numeric value for the EmployeeID (e.g. 147). I have only extracted the code that is giving the error. I have compared the whole code and it is exactly the same so it must be somthing in the PHP.ini or Mysql set up.

Again sorry if this does not make sence.
 
the error is quite clear:

Code:
Database error: Invalid SQL: SELECT COUNT(*) FROM Employees_Certs LEFT JOIN Suppliers ON Employees_Certs.SupplierID = Suppliers.SupplierID WHERE [red]Employees_Certs.EmployeeID = AND[/red] Suppliers.CompanyID = 1

As you can see, there is no parameter to compare, so the SQL statment is incorrect. Now, that parameter is got from [tt]$this->SQLValue($this->wp->GetDBValue("1"), ccsInteger)[/tt] which should be the problem, it is not getting any value.

Cheers.
 
You say that the employeeID is coming from a form. How are you referencing the form field, via the $_POST super array? If not, then that's probably you're problem.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top