Skip site navigation (1) Skip section navigation (2)

Re: Error with query

From: Christian Ramseyer <rc(at)networkz(dot)ch>
To: Helgi Örn Helgason <sacredeagle(at)gmail(dot)com>
Cc: PostgreSQL - newbie <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Error with query
Date: 2010-10-07 08:32:55
Message-ID: 4CAD85B7.5070803@networkz.ch (view raw or flat)
Thread:
Lists: pgsql-novice
On 10/7/10 10:26 AM, Christian Ramseyer wrote:
>>
>> $query = "INSERT INTO timmar(pack_date, pack_week, pack_day, pack_pts,
>> pack_name, pack_tidin, pack_tidut, pack_lunch) VALUES('" . $pack_date
>> . "', '" . $pack_week . "', '" . $pack_day . "', '" . $pack_pts . "',
>> '" . $pack_name . "', '" . $pack_tidin . "', '" . $pack_tidut . "', '"
>> . $pack_lunch . "')";
>> $result = pg_query($query);
>> if (!$result) {
>>     $errormessage = pg_last_error();
>>     echo "Error with query: " . $errormessage;
>>     exit();
>> }

Or if you don't like to use prepared statement, you could still drop all
these string concatenations since PHP expands variables in single quotes
that are already in double quotes:

rc(at)asado-263:~ $ cat foo.php

<?php
$x = "blah";
echo "x = '$x'\n";
?>

rc(at)asado-263:~ $ php foo.php
x = 'blah'



In response to

pgsql-novice by date

Next:From: Jean-Yves F. BarbierDate: 2010-10-07 08:52:45
Subject: log into a table
Previous:From: Christian RamseyerDate: 2010-10-07 08:26:24
Subject: Re: Error with query

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group