<?php

set_time_limit(0);
$link = peb_pconnect("bryndlir@127.0.0.1 ", "abc");
if ($link) {
    echo "linked!:" . $link . "<br>\r\n";
} else {
    echo "error:" . peb_errorno() . "<br>\r\nerror:" . peb_error() . "<br>\r\n";
}
echo "<br>\r\n";
echo "<br>\r\n";
peb_status();
echo "<br>\r\n";
echo "<br>\r\n";
$x = peb_vencode("[~a,~a]", array(array("hello", "friend")));
echo "msg resource :" . $x . "\r\n";
echo "<br>\r\n";
echo "<br>\r\n";
peb_send_byname("pong", $x, $link);
echo "<br>\r\n";
echo "<br>\r\n";
//peb_close($link);  You don't need to close pconnect :)
}
if (!$doesExist) {
    $sql = "INSERT INTO myhistory (twitter_id, hashtag, uses)\nVALUES ('{$twitter_id}','{$theHashtag}' ,'{$uses}')";
    if ($db->query($sql) === TRUE) {
    } else {
        echo "Error: " . $sql . "<br>" . $db->error;
    }
} else {
    $sql2 = "UPDATE myhistory SET uses = '{$uses}' where (hashtag = '{$theHashtag}' and twitter_id = '{$twitter_id}')";
    if ($db->query($sql2) === TRUE) {
    } else {
        echo "Error: " . $sql . "<br>" . $db->error;
    }
}
$serverpid = $rs[0][0];
$message = peb_vencode('[~s]', array(array($_GET['hashtag'])));
//peb_send_bypid($serverpid,$message,$link);
//just demo for how to use peb_send_bypid
peb_close($link);
?>
<h2 class="col-sm-6 col-sm-offset-3">  <b>#<?php 
echo $theHashtag;
?>
   has been used <?php 
echo $uses;
?>
 times! </b> </h2> <br>
    

        
                    <!--Twitter Authentication  removed so far. (can only log in before searching)