Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Paste Description for Yancho

The read from DB and echo row script described in PUGMT

Yancho
Tuesday, December 18th, 2007 at 7:16:42pm MST 

  1. <?php
  2. //session_start();
  3.  
  4. // The file which gets the data from the table to echo
  5.  
  6. include 'db.php';
  7. $con = pg_connect("dbname=".$db." host=".$dbhost." user=".$dbuser." password=".$dbpass)
  8.       or die ("PostgreSQL Error --> " . pg_last_error($con));
  9.  
  10.  
  11.  $ip = $_SERVER['REMOTE_ADDR'];
  12.  
  13. //if (isset($_COOKIE['tid'])) { $tid = $_COOKIE['tid']; }
  14. //else { $tid = $_SESSION['tid']; }
  15.  
  16. //echo "tid is : $tid";
  17. //print_r ($_SESSION);
  18. //print_r ($_COOKIES);
  19.  
  20.  
  21. $query = "SELECT coalesce ((SELECT tid from xml where ip = '".$ip."' order by id ASC limit 1), 'null');"  ;
  22.  
  23. //echo $query ;
  24.  
  25. $sql = pg_query ($query) ;
  26.  
  27. $respg_fetch_assoc($sql) ;
  28.  
  29. $exists = $res['coalesce'];
  30.  
  31.  
  32. if ( $exists != "null" ) {
  33.  
  34.         $query2 = "SELECT tid, id, line from xml where ip = '".$ip."' order by id ASC limit 1;"  ;
  35.        
  36.         //echo $query2;
  37.  
  38.         $sql2 = pg_query ($query2);
  39.  
  40.         $result = pg_fetch_assoc($sql2);
  41.  
  42.         //print_r ($result);
  43.        
  44.         $tid = $result['tid'];
  45.  
  46.         $line2 = $result['line'];
  47.        
  48.         if ( $line2 != "<br><b>Welcome to destination - Hope you enjoyed your trip</b>" ) {
  49.        
  50.             $now = date("H:i:s");
  51.            
  52.             $line = $now." ".$line2;
  53.         }
  54.         else {
  55.           $line = $line2 ;
  56.         }
  57.  
  58.         $id = $result['id'];
  59.  
  60.         $_SESSION['last_inst'] = $line;
  61.         //setcookie("last_int",$line, time()+1200);
  62.  
  63.         ob_start();
  64.         echo $line;
  65.        
  66.         ob_end_flush();
  67.  
  68.  
  69.  
  70.  
  71.         // now deleting the line
  72.  
  73.         $dquery = "delete from xml where (tid = '".$tid."' and id = '".$id."');" ;
  74.         //echo $dquery;
  75.         $dquery = pg_query ($dquery);
  76. }
  77. else {
  78.  
  79.  echo $_COOKIE['last_inst'];
  80.    }
  81.  
  82. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation