robeh
Posts: 17
|
| Posted: 10/23/2005, 5:56 AM |
|
My WHERE clause is reading the wrong thing for the name of the database column, and I can't figure out why. Here's the part of the code doing this:
$ctype = $parshaSet->ds->type->GetValue() %100;
$cparsha = $parshaSet->ds->parsha->GetValue();
$db = new clsDBConnectTonsleining();
$id = CCDLookUp("parsha_id", "parshas", "yeartype = ".$ctype." AND parsha = ".$cparsha,$db);
The error is Invalid SQL: SELECT parsha_id FROM parshas WHERE yeartype = 2 AND parsha = Bre
MySQL Error: 1054 (Unknown column 'Bre' in 'where clause')
yeartype is fine, but the parsha is a problem - the column name is parsha, not Bre - Bre is a particular field.
What am I doing wrong?
Thanks.
Robert
|
 |
 |
DonB
|
| Posted: 10/23/2005, 8:44 AM |
|
You need quotes/apostrophes for string data types otherwise SQL's rule is
'assume it's a column name'
--
DonB
http://www.gotodon.com/ccbth
"robeh" <robeh@forum.codecharge> wrote in message
news:5435b887a726f6@news.codecharge.com...
> My WHERE clause is reading the wrong thing for the name of the database
column,
> and I can't figure out why. Here's the part of the code doing this:
>
> $ctype = $parshaSet->ds->type->GetValue() %100;
> $cparsha = $parshaSet->ds->parsha->GetValue();
> $db = new clsDBConnectTonsleining();
> $id = CCDLookUp("parsha_id", "parshas", "yeartype = ".$ctype." AND parsha
=
> ".$cparsha,$db);
>
> The error is Invalid SQL: SELECT parsha_id FROM parshas WHERE yeartype = 2
AND
> parsha = Bre
> MySQL Error: 1054 (Unknown column 'Bre' in 'where clause')
>
> yeartype is fine, but the parsha is a problem - the column name is parsha,
not
> Bre - Bre is a particular field.
>
> What am I doing wrong?
>
> Thanks.
>
> Robert
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
robeh
Posts: 17
|
| Posted: 10/23/2005, 5:06 PM |
|
DonB,
Thanks for the information. Everything is happy now.
Robert
|
 |
 |
|