(1) should not be valid either.  first_name is not part of your select 
statement.  So, how would you be able to order your result set with it? 
I think what Hytham wants to do here is dynamically build an SQL 
statement.  Your SQL string should be built before you try to prepare it.

-Ian

Paul DuBois wrote:

> At 18:05 +0300 6/10/02, Hytham Shehab wrote:
>
>>  hi all of u,
>>      i got a simple question, why (1) is valid, however, (2) is not ?!!
>>  (1) sorting order is explicity typed in the query statement:
>>   $sth = $dbh->prepare("select student_name from students order by
>> first_name
>>  asc");
>>  $sth->execute();
>>  (2) sorting order is passed as a bind parameter:
>>  $sort = 'asc';
>>  $sth = $dbh->prepare("select student_name from students order by 
>> first_name
>>  ?");
>>  $sth->execute($sort);
>
>
> Because placeholders are valid only for data values, not for keywords
> or identifiers.
>
>>  thx v. much
>>  --
>>  Hytham Shehab
>
>



Reply via email to