<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html>
<head>
        <title></title>
        
<meta name="GENERATOR" content="MSHTML 8.00.6001.18876"></meta>
</head>

<body>
        
<div>Hi</div>
        
<div> </div>
        
<div>when you are using capitals in column name you have to use " around column name:</div>
        
<div>I am not good in php so I don't remember if it is ok to just double the " sign inside a string like</div>
        
<div> </div>
        
<div>$sql = "INSERT INTO countries (""CountryID"", ""CountryName"", ""President"") VALUES .....</div>
        
<div> </div>
        
<div>What I use to do is avoiding capitals in column names :-)</div>
        
<div> </div>
        
<div>/Nicklas<br />
                <br />
                2010-03-11 Linnet Kwamboka wrote:<br />
                <br />
                hey guys,<br />
                >i dont know is anyone can help me i have been having trouble.<br />
                >i am using the follonwing code to do an INSERT query <br />
                ><br />
                ><br />
                ><br />
                ><br />
                >
<!--
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
-->
<br />
                > <br />
                >    <br />
                >          <br />
                ><br />
                > 
<!--
p<br
-->
> if ($_POST['submit']) {<br />
                >     // attempt a connection<br />
                >     $dbh = pg_connect("host=localhost dbname=postgres user=postgres password=quash");<br />
                >      if (!$dbh) {<br />
                >         die("Error in connection: " . pg_last_error());<br />
                >     }<br />
                >     else{<br />
                >     echo "this was okay";<br />
                >     }<br />
                >    //exit; <br />
                >    <br />
                >     // escape strings in input data<br />
                >     // $code = pg_escape_string($_POST['code']);<br />
                >//$name = pg_escape_string($_POST['name']);<br />
                >    //$president = pg_escape_string($_POST['president']);<br />
                >    <br />
                >     // execute query<br />
                >     $sql = "INSERT INTO countries (CountryID, CountryName, President) VALUES('{$_POST['code']}', '{$_POST['name']}', '{$_POST['president']}')";<br />
                >      $result = pg_query($dbh, $sql);<br />
                >     if (!$result) {<br />
                >         die("Error in SQL query: " . pg_last_error());<br />
                >     }<br />
                >    <br />
                >     echo "Data successfully inserted!";<br />
                >    <br />
                >     // free memory<br />
                >      pg_free_result($result);<br />
                >    <br />
                >     // close connection<br />
                >     pg_close($dbh);<br />
                > }<br />
                > ?>       <br />
                ><br />
                >    </div>
        
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><br />
                >       Country code: <br />
                
                <input size="2" name="code" />  <br />
                >      
                
<p><br />
                        >      Country name: <br />
                        
                        <input name="name" />       <br />
                        >       </p>
                
<p><br />
                        >       President's name: <br />
                        
                        <input name="president" />       <br />
                        >      </p>
                
<p><br />
                        >      
                        <input value="Send forespørsel" type="submit" name="submit" /><br />
                        >     <br />
                        >   <br />
                        >   <br />
                        > <br />
                        ><br />
                        ><br />
                        ><br />
                        ><br />
                        >but i am getting the following error<br />
                        ><br />
                        > this was okay<br />
                        ><b>Warning</b>: pg_query() [<a href="http://localhost/bongamate/function.pg-query" target="_blank">function.pg-query</a>]: Query failed: ERROR: column "countryid" of relation "countries" does not exist LINE 1: INSERT INTO countries (CountryID, CountryName, President) VA... ^ in <b>C:\xampp\htdocs\bongamate\weka.php</b> on line <b>25</b><br />
                        > Error in SQL query: ERROR: column "countryid" of relation "countries" does not exist LINE 1: INSERT INTO countries (CountryID, CountryName, President) VA... ^<br />
                        ><br />
                        ><br />
                        >can anyone help me on this? thank you<br />
                        > with regards geekmate!<br />
                        ></p>
        </form>
</body>
</html>