This is my code:
<?php
$dbconn = pg_connect("host=*** dbname=*** user=*** password=***")
or die('Could not connect: ' . pg_last_error());
echo("test");
?>
Nothing shows up. Please help..




Posted 04 July 2012 - 09:28 AM
<?php
$dbconn = pg_connect("host=*** dbname=*** user=*** password=***")
or die('Could not connect: ' . pg_last_error());
echo("test");
?>
Posted 04 July 2012 - 10:42 AM
ini_set('display_errors', true);
error_reporting(E_ALL);
<?php
if (!isset($_POST['email'], $_POST['name'], $_POST['whatever'])) {
die("Email, name and whatever expected as POST data.");
}
try {
// Connect to PostgreSQL, and have it throw exceptions when
// errors occur.
$dbLink = new PDO("pgsql:host=localhost;dbname=testdb", "User", "PWD");
$dbLink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
die("Failed to connect to PostgreSQL : " . $e->getMessage());
}
try {
// Insert a row of data based on user supplied POST values.
// Because I use a prepared statement, the threat of
// SQL Injection is avoided completely!
$sql = "INSERT INTO stuff (email, name, whatever)
VALUES(:email, :name, :whatever)";
$stmt = $dbLink->prepare($sql);
$stmt->bindValue(':email', $_POST['email']);
$stmt->bindValue(':name', $_POST['name']);
$stmt->bindValue(':whatever', $_POST['whatever']);
$stmt->execute();
if ($stmt->rowCount() === 1) {
echo "Record inserted!";
}
else {
echo "Failed to insert record!";
}
}
catch (PDOException $e) {
die("Failed to insert record: " . $e->getMessage());
}
$dbLink = new PDO("mysql:host=localhost;dbname=testdb", "User", "PWD");
Posted 04 July 2012 - 12:53 PM
This post has been edited by Lazy Vulpes: 04 July 2012 - 12:54 PM
Posted 04 July 2012 - 02:03 PM
$dblink->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
This post has been edited by e_i_pi: 04 July 2012 - 02:04 PM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
