Jump to content
Old threads will finally start getting archived ×

dumb2champ

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by dumb2champ

  1. Hello there.. I have a problem when loading comment from my database.. Here are working scripts which does not query the message/comment from database.. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "responder"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //query the user table $sql = "SELECT * FROM user"; $result = $conn->query($sql); //get comment from array $comment = $_GET['comment'] + 1; //I want to replace below array comment with my database comment $ar = array( "Hello there.", "How are you?" ); require_once("facebook.php"); $config = array(); $config['appId'] = 'myapp'; $config['secret'] = 'mysecret'; $config['fileUpload'] = false; $fb = new Facebook($config); if ($result->num_rows > 0) { foreach ($result as $key) { $params = array( //long-live-token "access_token" => $key['offense_token'], //comment //need to replace this from database "message" => $ar[$comment], ); if($comment<10) { try { $ret = $fb->api('/my-comment-id/comments', 'POST', $params); echo 'Successfully posted to Facebook'; sleep(5); header('Location: set-comment.php?comment='.$comment); } catch(Exception $e) { echo $e->getMessage(); } } else{ echo "done"."<br>"; } } } ?> Above scripts working fine without querying from my database So my issues now, how do I query and loop each comment from database? Here my comment/message table.. TQ
  2. Hello everyone.. I have a question to delete comment based from user-id itself. I use PHP SDK to delete any comment to my facebook page and it was success as long as I specify the comment-id.. Below are my codes to delete a comment from comment-id $request = new FacebookRequest( $session, 'DELETE', '/{comment-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); Is it possible to delete comment based on user-id itself? I know that I just need to query the graph api to get the comment-id from A but each comment have different id`s so its hard to query the comment-id everytime.. For example: A, B, and C comment to my facebook post and I want to delete the comment where the user-id is from A? So, if the api scan and found out that A is commenting to my post, it will be deleted instead deleting B and C I really appreciate for any help from you guys.. Thanks
  3. What i mean was to output <q_name> object..thanks
  4. Thanks Barrand.. One more question..i dont quite understand the codes which is: foreach ($xml2->xpath('//item') as $i) { $a1[(string)$i->q_id] = (int)$i->value; } If i want to add another object say, <q_name>This is Q1<q_name> after <q_id> which is like this: <item> <q_id>4131001</q_id> <q_name>This is Q1<q_name> <----- <value>7</value> </item> How to edit the scripts?
  5. I got Notice: Undefined offset: 4131001 Output 4131001 Notice: Undefined offset: 4131001 on line 17 10 4232002 5
  6. sory the result should be 3 and 5...sory
  7. Hello... I want to calculate the value from 2 difference files using simplexml load file... But the result not as expected.. My output should be 7 and 5 where 10 - 7 and 8 - 3. My first xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>10</value> </item> <item> <q_id>4232002</q_id> <value>8</value> </item> </items> My second xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>7</value> </item> <item> <q_id>4232002</q_id> <value>3</value> </item> </items> My scripts. <?php $xml = simplexml_load_file('q1.xml'); $xml2 = simplexml_load_file('q2.xml'); foreach ($xml -> item as $item) { $value1 = $item->value; echo $item->q_id.'<br />'; //echo $value1.'<br />'; foreach ($xml2 -> item as $item2) { $value2 = $item2->value; $total = $value1 - $value2; echo $total.'<br />'; } } ?> The result should be 7 and 5 where 10 - 7 and 8 - 3 but there is another unknows value which is 3 and 1... How to solve the issue.. Thank for any help..
  8. thanks...problem solve
  9. Thanks for ur reply I just edit the codes and turn on error reporting...but no error occur I also update fclose after the loop...the result are same So why does the tabs/spaces exist? Do i need to add anything to trim/strip the black space/tabs? But when im echoing the output there`s blank spaces/tabs exist.. thanks
  10. Hello... I have problem concerning in php fwrite function... Each time i run the codes, it will add blank spaces/tab for every loop... My screenshot My Codes //create a file $fileCreate = fopen("test.txt","w") or die("Unable to open file!"); foreach ($in_xml_river->item as $item) { $pushData = $item->station_id."::LEVEL\r\n"; fwrite($fileCreate, $pushData); fclose($fileCreate) } Please help me out to solve this issue...thanks
  11. Thanks CroniX...thanks.. That what i want to achieve... I have done step 1 now to step 2... but seriously im new in this framework and js.... i hope you can help if there problem in my codes... thanks
  12. Ok..thanks for ur reply and solution but i know how to achieve ur solution... sorry...what i want is to refresh the view if theres new created data either from client(view)/server(database) side i know ajax can do the job by using setintervel if i not mistaken.... but i dont know how to make it to work with my scripts.... another solution is again using ajax by returning newest created item in database(timestamp).. u can see that my database keep track of any created/updated data.... thanks for ur time....i hope u can help me with the simplest solution by applying ajax to my scripts... thank you
  13. Thanks Anemic for ur respond... Yeah auto refresh the page can do the work but how to return only new data without getting all data in database? it is using ajax? How to achieve that?can you provide example...with my codes... Thanks...
  14. Hello... Im just started to codes in Laravel 5... I need help to auto update my view when theres new data in database... Below are screenshot of my view... this is my supplycontroller class SupplyController extends Controller { /** * Display a listing of the resource. * * @return Response */ public function index() { $supplies=Supply::all(); return view('supplies.index',compact('supplies')); } Below are my index.blade.php @extends('layout/template') @section('content') <h1>Supplies</h1> <a href="{{url('/supplies/create')}}" class="btn btn-success">Create Supply</a> <hr> <div class="ref"> <table class="table table-striped table-bordered table-hover"> <thead> <tr class="bg-info"> <th>Id</th> <th>Items</th> <th>Desc</th> <th colspan="3">Actions</th> </tr> </thead> <tbody> @foreach ($supplies as $supply) <tr> <td>{{ $supply->id }}</td> <td>{{ $supply->supply_item }}</td> <td>{{ $supply->supply_desc }}</td> <td><a href="{{url('supplies',$supply->id)}}" class="btn btn-primary">Read</a></td> <td><a href="{{route('supplies.edit',$supply->id)}}" class="btn btn-warning">Update</a></td> <td> {!! Form::open(['method' => 'DELETE', 'route'=>['supplies.destroy', $supply->id]]) !!} {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!} {!! Form::close() !!} </td> </tr> @endforeach </tbody> </table> </div> @endsection My database... Im really appriciate for anyone to help with examples... It it using javascripts?ajax? How to achieve the auto update view which return only updated/new data in database... Thanks
  15. thanks...i try it...nice pic
  16. Please help regarding scraping website using Xpath... I want to scrap the main content of a website..but theres a problem...the scripts does not return all content but only the first line of content at main body of website... Scripts like below.... <?php //sentimen order if (PHP_SAPI != 'cli') { echo "<pre>"; } require_once __DIR__ . '/../autoload.php'; $sentiment = new \PHPInsight\Sentiment(); require_once 'Xpath.php'; //my target website $startUrl = "http://news.sky.com/story/1445575/suspect-held-over-shooting-of-ferguson-police/"; $xpath = new XPATH($startUrl); // my specific filter $query = '/html/body/div[2]/div[3]/article/div/div[2]/div[2]'; //start xpath $strQuery = $xpath->query($query); $strNode = $strQuery->item(0)->nodeValue; //THE PROBLEM START HERE..ARRAY SCRIPTS SEEMS WRONG.... $result = array($strNode); //HERE ALSO foreach ($result as $string) { // calculations: $scores = $sentiment->score($string); $class = $sentiment->categorise($string); // output: echo "Strings $string \n"; echo "Dominant: $class, scores: "; print_r($scores); echo "\n"; } The scripts output only single line of sentiment but not all the required content... The problem come from array and foreach... Please help to repair these scripts...Thanks
  17. You guys help me alot...i`m really stupid...thanks alot...kicken and barand
  18. Thanks kicken.. I really appreciate alot...but how to summarise which classes are most used(neg,neu,pos) from above result...not from each string but whole strings...
  19. I use PHPInsight scripts which provide opinion mining test. Below are example codes that provide scores and it class either positive, negative, or neutral <?php //sentimen order if (PHP_SAPI != 'cli') { echo "<pre>"; } $strings = array( 1 => 'Weather today is rubbish', 2 => 'This cake looks amazing', 3 => 'His skills are mediocre', 4 => 'He is very talented', 5 => 'She is seemingly very agressive', 6 => 'Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.', 7 => 'To be or not to be?', ); require_once __DIR__ . '/../autoload.php'; $sentiment = new \PHPInsight\Sentiment(); foreach ($strings as $string) { // calculations: $scores = $sentiment->score($string); $class = $sentiment->categorise($string); // output: echo "String: $string\n"; echo "Dominant: $class, scores: "; print_r($scores); echo "\n"; echo $a; } Result from above scripts => http://postimg.org/image/bf6fugyo5/ The result show scores and classes of each strings... But how to summarize total scores and classes of entire strings??? For example if negative more(>) than positive, then total class will be negative and vice versa. And also total scores of each string into one single scores which not more than 1 Kindy need help...thanks
  20. sorry...nevermind...issues solve..
  21. How to convert following perl scripts to php.... my ( $ServiceSet, $Service ); eval { $ServiceSet = Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2")-> ExecQuery("SELECT * FROM Win32_Service WHERE State=\"Running\""); }; unless ($@) { print "\n"; foreach $Service (in $ServiceSet) { print $Service->{Name}, "\n"; if( $Service->{Description} ) { print " $Service->{Description}\n"; } else { print " <No description>\n"; } print " Process ID: ", $Service->{ProcessId}, "\n"; print " Start Mode: ", $Service->{StartMode}, "\n"; print "\n"; } } Above code shows running services from win32_service that i`m taken from http://msdn.microsoft.com/en-us/library/aa394418%28v=vs.85%29.aspx... Please help.. i want to display running services and display it in table form??? Thank You...
  22. Ok I`ll will explain to you detail of what i`m trying to achieve... I have a list of IP(sorry) on my network...and I have succeed ping out all the ranges of IP from table list... So what I trying to figure is how to display their OS name??? I dont know how to do...I`ve to search out about $user_agent...but i dont know how to used it... i`ll also have try diff function including gethostbyaddr,gethostbyname,etc but with my host, it succed but other host not succed.. If i`ll use $user_agent how to do it to display OS name of my list of network host??? Thank for your concern...it been hour try to search at diff forum,google but not succed....
  23. I have list of ip on my network(neighbor,staff)...so i want to create a scripts that perform OS name detection from the list table....Help me
  24. Yes that right.. Can you help me out??
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.