<?php
$connect = pg_connect("dbname=$dbase host=".$host." user=".$user." password=".$pass) or die("I sense a disturbance in the force ");
$action = $_POST['action'];
switch($action){
case 'bagSubmit' : bagSubmit(); break;
}
function bagSubmit(){
$sql = 'SELECT * FROM cntrt';
$query = pg_query($connect,$sql) or die('could not connect');
}
?>
The above php returns ‘could not connect’. The sql query executes fine in the database. This is my normal procedure for executing queries in php (always worked before). The only difference now is that I am calling the php from jquery. The jquery is executing fine as well, as evidenced by the fact that the query’s failure (‘could not connect’) is returned. What am I missing?
$.ajax({
url: 'functions.php',
data: {action: 'bagSubmit'},
type: 'post',
success: function(response){
$('body').append(response);
}
});
1 Answer