Sunday, 15 August 2010

javascript - Cannot use echo after connection to database -


I am using Ajax to send requests for php from some text.

  $ .get ("process.php", {finalQuery: finalQuery}, function (data) {warning ("data loaded:" + data);});  

I know this job because I can put

  $ val = $ _GET ['finalQuery'] in php; Resonate $ val;  

and it shows the correct data, however, if I

  $ db = pg_Connect ("host = localhost port = 5432 dbname = blah user = postgres password = 1888 "); Pg_close ($ Database);  

This stops reverting the results back to Javascript if I use a different port or name, and it does not connect, then send the data to javascript and right Data goes back to output.

So basically, when I connect to the database, I can not refund my results with echo. I am doing the wrong

Edit ( Updates):? Full php code here

  & lt; Php $ val = $ _GET ['finalQuery']; Resonate $ val; $ Db = pg_Connect ("host = localhost port = 5432 dbname = blah user = postgres password = 1888"); $ Result = pg_query ($ db; Choose from "GID FROM" Perfect "'); While ($ line = pg_fetch_row ($ result)) {resonant "gid: $ line [0]"; Echo "
; \ n"; } Pg_close ($ db); ? & Gt; However, the problem still occurs until all the lines I use using pg_connect can be removed and the problem persists as long as I remove pg_connect, the problem Disappears and I can send information back via echo

New edit (debugging):

The connection database and php code are correct After loading with php page

  error_reporting (-1); Ini_set ('display_errors', 'on'); No errors are logged on the page, and connection to the database is returning all the data properly on all page loads. 

The problem occurs when I'm trying to connect to PHP via Javascript.

The page sometimes loads the data properly, but it is random, and most of the time (nothing is php log errors). If you have no way, then JavaScript-PHP connection If the problem is not there, I'll debugging the code.

itemprop = "text">

Here are the steps I would like to debug:

  1. Begin by making sure DB Running through and you can send a question successfully through the console window DB GUI tool (Navicat is my GUI that's preferred for DB)
  2. Load the PHP page directly to the expected code or Fatal PHP Check the output of errors
  3. Check for Browser Console for errors as it is a PHP page appears the same, so it should be completely clear of problems.
  4. Check PHP Logs
  5. Check Postgrass Logs

There is a problem between postgres and PHP more than the possibility.

If you are still stuck after finding a clue then post back any errors on your question.

No comments:

Post a Comment