Solved

Insert data into postgres Database script needed

Posted on 2011-03-09
2
519 Views
Last Modified: 2012-05-11
Hi all,

I need some simple code that does just the following:

Hope the below describes what I need:

<a href="">Save to Database Table</a> //A link here to activate the saving

var $value1='200';  
var $value2='blablabla';

etc...

...then something like:

pg_query("INSERT INTO myTable VALUES ('$value1','$value2','$fvalue3','$value4')");

echo 'Data has been saved';

//the end

Can anyone help put a script together to do the above please?

Thanks


0
Comment
Question by:error77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 35081642
Maybe like this:

<?php

if(isset($_GET[save]) && $_GET[save] == 1){
$conn = pg_pconnect("dbname=yourdb");
$query = "INSERT INTO myTable VALUES ('$value1','$value2')";
pg_query($conn, $query);
echo"saved";
}
?>

<?php
    var $value1='200';  
    var $value2='blablabla';
    
    echo"values: v1: $value1, v2: $value2";
?>

<a href="index.php?save=1">Save to Database Table</a> //A link here to activate the saving

Open in new window

0
 

Author Closing Comment

by:error77
ID: 35083799
Perfect! thanks a lot.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to implement server side field validation and display customized error messages to the client.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
The viewer will learn how to dynamically set the form action using jQuery.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question