postgresql-7.2.3-5.80 error

Christopher Murtagh yellowdog-general@lists.terrasoftsolutions.com
Wed Jun 4 07:05:01 2003


On Tue, 3 Jun 2003, Harold Shanafield wrote:
>I am trying to do a routine insert into a table in psql and I am getting
>a ERROR:  parser: parse error at or near ";".  When I try to submit the
>insert via php I get a record inserted, but all of the fields are blank.

 This means that your SQL syntax is bad. One thing that can be causing it 
is when you are trying to insert an integer with a variable that is 
blank/null. For example:

<?

 $MyVar = '';
 pg_exec($Connection,"INSERT INTO table VALUES(1, $MyVar);");

?>

 will generate an error, because the SQL query becomes:

 "INSERT INTO table VALUES(1,);"

 However, if you did this:

 $MyVar = intval($MyVar);

 before your insert statement, it would work. This way your SQL query 
would become:

 "INSERT INTO table VALUES(1,0);"

 
 Hope this helps.

Cheers,

Chris

-- 

Christopher Murtagh
Webmaster / Sysadmin
Web Communications Group
McGill University
Montreal, Quebec
Canada

Tel.: (514) 398-3122
Fax:  (514) 398-2017