Reputation: 3729
I have tried variations of this:
$prep_get_company=$connection->prepare("SELECT * FROM sl_customer WHERE company_name = ':company_name'");
$prep_get_company->bindParam(':company_name',$company_name);
and I get no results but if I do this:
$prep_get_company=$connection->prepare("SELECT * FROM sl_customer WHERE company_name = '$company_name'");
It returns my desired results. The contents of $company_name
is a string with spaces.
Upvotes: 0
Views: 57
Reputation: 19528
Remove the single quotes on your query:
SELECT * FROM sl_customer WHERE company_name = ':company_name'
Should have been:
SELECT * FROM sl_customer WHERE company_name = :company_name
The single quote will treat it as a literal value which would make your prepared statement fail to bind as it think there is nothing to bind when using the single quotes.
The prepared statement will by itself arrange the data you're binding to it as needed.
Upvotes: 1