pg_query won't execute

Поиск
Список
Период
Сортировка
От Dale Schmitz
Тема pg_query won't execute
Дата
Msg-id 000301d3b3f4$da473c10$8ed5b430$@cox.net
обсуждение исходный текст
Ответы Re: pg_query won't execute  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice

I’m learning PHP for PostgreSQL and have come across something I can’t figure out.

 

The statement “SELECT COUNT(*) FROM users WHERE username = ‘john’ works just fine in the pgAdmin query tool, but not like this:

 

$sql = “SELECT COUNT(*) FROM users WHERE username = $username”;

If ($result = pg_query($dbconn,$sql)) {

                …process statements…

} else {

                echo “Could not execute $sql”;

}

 

$dbconn is a valid resource (I’ve changed up the $sql statement to test, and it works just fine), so no problem there.  The problem is incurred when I attempt to COUNT something.

 

Is there a different method I should be using for returning a count?

 

Thanks

Dale

В списке pgsql-novice по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: "invalid input syntax for integer" for number with exponent
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_query won't execute