Inserting into a Database
Posted: Thu Dec 19, 2002 3:52 am
I am attempting to Insert a value into a Foreign Key column in a postgresql table. I am in the databases forum with this one too! I was wondering if there is anything in PHP I am doing wrong when passing the variables in, this is my code:
include("classes/dbConnector.class.php");
//create an object of the dbConnector class
$db = new dbConnector();
$conn_string = "host=127.0.0.1 port=5432 dbname=filemanager user=pgsql password=postgres";
$connect = $db->dbConnect($conn_string);
if (!$connect)
{
die("Could not open connection to database server");
}
$query = "INSERT INTO directories (directoryname,datecreated,uid) VALUES ('$newdir',now(),'$uid')";
$result = $db->dbExecQuery($connect, $query) or die("Error in query: $query . " . pg_last_error($connect));
//close database connection
$db->dbClose($connect);
This is the Error I am recieving:
Warning: pg_last_error(): 1 is not a valid PostgreSQL link resource in /usr/local/www/data-dist/filemanager/makedir.php on line 81
Error in query: INSERT INTO directories (directoryname,datecreated,uid) VALUES ('hello',now(),'1') .
Can anyone help?
include("classes/dbConnector.class.php");
//create an object of the dbConnector class
$db = new dbConnector();
$conn_string = "host=127.0.0.1 port=5432 dbname=filemanager user=pgsql password=postgres";
$connect = $db->dbConnect($conn_string);
if (!$connect)
{
die("Could not open connection to database server");
}
$query = "INSERT INTO directories (directoryname,datecreated,uid) VALUES ('$newdir',now(),'$uid')";
$result = $db->dbExecQuery($connect, $query) or die("Error in query: $query . " . pg_last_error($connect));
//close database connection
$db->dbClose($connect);
This is the Error I am recieving:
Warning: pg_last_error(): 1 is not a valid PostgreSQL link resource in /usr/local/www/data-dist/filemanager/makedir.php on line 81
Error in query: INSERT INTO directories (directoryname,datecreated,uid) VALUES ('hello',now(),'1') .
Can anyone help?