
dumb2champ
Members-
Posts
33 -
Joined
-
Last visited
dumb2champ's Achievements

Member (2/5)
0
Reputation
-
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
-
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
-
Simplexml calculate 2 value from 2 files
dumb2champ replied to dumb2champ's topic in PHP Coding Help
What i mean was to output <q_name> object..thanks -
Simplexml calculate 2 value from 2 files
dumb2champ replied to dumb2champ's topic in PHP Coding Help
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? -
Simplexml calculate 2 value from 2 files
dumb2champ replied to dumb2champ's topic in PHP Coding Help
I got Notice: Undefined offset: 4131001 Output 4131001 Notice: Undefined offset: 4131001 on line 17 10 4232002 5 -
Simplexml calculate 2 value from 2 files
dumb2champ replied to dumb2champ's topic in PHP Coding Help
sory the result should be 3 and 5...sory -
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..
-
php fwite add blank spaces from each loop
dumb2champ replied to dumb2champ's topic in PHP Coding Help
thanks...problem solve -
php fwite add blank spaces from each loop
dumb2champ replied to dumb2champ's topic in PHP Coding Help
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 -
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