Re: creating table w/ php help

Поиск
Список
Период
Сортировка
От David A Dickson
Тема Re: creating table w/ php help
Дата
Msg-id Pine.LNX.4.33.0204191726100.22117-100000@blues.wcg.mcgill.ca
обсуждение исходный текст
Ответ на creating table w/ php help  (webmaster <webmaster@harbornet.com>)
Список pgsql-general
On Fri, 19 Apr 2002, webmaster wrote:
> Warning: Wrong parameter count for pg_exec() in
> /var/www/html/elkan/createtable.php on line 23
> The table, ghdsl could not be created
>
> Here is the code I'm using:
>
> <?php
>
> // set variables
> $tablename = "ghdsl";
> $dbname = "testingdb";
> $user = "testinguser";
> $password = "xxxxxx";
>
> $connect = "pg_connect($dbname, $user, $password)";

Here is the first problem. $connect should be a resource, not a string.
Try this:
    $connect = pg_connect ("dbname=$dbname user=$user
password=$password");

> $query = "CREATE table $tablename (id INT UNSIGNED NOT NULL
> AUTO_INCREMENT PRIMARY KEY, ip TEXT, customer TEXT, dslphone TEXT, date
> TEXT, vpivci TEXT)";
>
>  if (pg_exec($dbname, $query, $connect))

Here is the second problem. By looking at the php manual for the pg-exec
function (changed to pg-query in php 4) I see that the correct usage is
    pg_query (resource connection, string query)
Try changing your code to
    if (pg_query($connect, $query))...

>   {
>   print ("The table, $tablename was successfully created");
>   } else {
>   print ("The table, $tablename could not be created");
>   }
>
> ?>

If this doensn't work try consulting the online manual for php at
http://www.php.net/manual/en/


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: ROWTYPE as parameter to function
Следующее
От: wsheldah@lexmark.com
Дата:
Сообщение: Re: Building perl mods pg:PG or DBD:PG on non