Solved

Insert data into postgres Database script needed

Posted on 2011-03-09
2
518 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

735 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