Jump to content

PHP87

New Members
  • Posts

    8
  • Joined

  • Last visited

PHP87's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a problem with the code generated by facebook like button. To resize the main page, facebook icons remain the same size, resulting in a disproportion between the elements of the page. How can I make a container resize also effective to facebook? Here is a sample of the container: <div class="fb-like-box" data-href="http://www.facebook.com/FacebookDevelopers" data-colorscheme="light" data-show-faces="false" data-header="false" data-stream="false" data-show-border="true"></div> I wish I could shrink and enlarge it at my leisure under all its elements are generated. Bye! Translated by google.
  2. Hello, i have a strange problem whit a javascript var. Ajax call don't works, because "var data" is too long. php: $var = json_encode($data); , or also: $var = implode(',', $data); //same problems with both javascript: var example_var = '<?php echo $var ?>'; $("#print").click(function(){ $.ajax({ type: "POST", url: "example.php", data: "example=" + example_var, dataType: "html", success: function(html) { $("#data").html(html); } }); }); The example works if i add '$var = substr("$var",0,-500);' in php code, for this i think the problem is var example_var, maybe is too long and the ajax calls don't work. Last: if i see the html source code var example_var is print correctly, but the ajax call don't work.
  3. Thank you very much. Now finally works. I create 3 pages: server.php, client.php and take_message,php. I have a problem now only whit this my two-easy script(1:index.php, 2:client.php): setInterval( function example(){ $.ajax({ type: "POST", url: "../chat/client.php", dataType: "html", success: function(html){ $("#read_chat").html(html); } }); },100); <?php $host = '127.0.0.1'; $port = 25003; $message = $_POST['message']; $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); socket_connect($socket, $host, $port) or die("Could not connect to server\n"); socket_write($socket, $message, strlen($message)) or die("Could not send data to server\n"); $result = socket_read ($socket, 1024) or die("Could not read server response\n"); echo $result; socket_close($socket); unset($message); ?> All two work exactly, but the read page is very slowed. How can I keep the page client.php waiting for a value different from the previous one?
  4. $json_decode = json_decode($json); $array = array('one' => 'two'); $array_two = json_encode($array); $array_three = json_decode($array_two); array_push($json_decode, $array_three); Same problem.
  5. Thank you for response, i choose json_encode() and json_decode(). Last question: $json = json_decode($json); $array = array('one' => 'one'); $array= json_encode($array); $array= json_decode($array); array_push($json, $array); Why array_push don't work?
  6. I'm new to the forum and I take this opportunity to say hello at everyone. I'm not an expert on php, but even a neophyte. That being said let's move to the problem, as mentioned in the title concerns the socket. Before putting the parts of the code that interest me start by saying that if to be sent through the socket is a simple sentence and not an array everything is working correctly, then the problem occurs only with an array. 1) client.php: $array = array('Say' => 'hello'); $socket = socket_create(AF_INET, SOCK_STREAM, 0); socket_connect($socket, $host, $port); socket_write($socket, $array, strlen($array)); $result = socket_read ($socket, 1024); 2)server.php: $output = array(); while(1){ $spawn = socket_accept($socket); $input = socket_read($spawn, 1024); array_push($output, $input); socket_write($spawn, $output, strlen ($output)); } Personally I think there is more than one error, first I would say that for example $ input is not an array, but it must contain a value that is an array, then would start already from here, also do not know if it is possible to send an array using sockets. And 'possible or do I have to split the array and I have to send the data twice? Translate from google, sorry for bad english. Bye!!
×
×
  • 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.