Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Błąd w moim skrypcie., "function: socket_create()"
yayco
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 2
Dołączył: 22.01.2008

Ostrzeżenie: (0%)
-----


Witam. Wiec mam juz skrypt na liste serwerów online pewnej gry...
Prawie wszystko działa tylko, przy dodawaniu serwerów przez uzytkownika
ukazuje sie taki błąd:

Cytat
<BR>Fatal error: Call to undefined function: socket_create() in /home/accounts_o/ots/public_html/lista/Pages/addserver.php on line 35


A tutaj kod źrdołowy plki addserver.php. co jest z linią 35 tego skryptu?

Kod


<?
if ($show == 1)
{
    if (isset($_SESSION['id']))
       {
          if (isset($_POST['submit'])){
             $ownerid = $_SESSION['id'];
             $ip = addslashes(htmlspecialchars($_POST['ip']));
             $port = addslashes(htmlspecialchars($_POST['port']));
             $desc = trim(htmlentities($_POST['desc'], ENT_QUOTES));
             $location = $_POST['location'];
             $connection = $_POST['connection'];

             $fel = 0;

             if (empty($desc)){
                $fel = 1;
                error("Wypełni pole opis.", 1);
             }
             $conn = @fsockopen ("$ip", "$port",$null,$errstr,1);
             if (!$conn)
                {
                $fel = 1;
                error("Nie można nawi&#261zać poł&#261czenia z serwerem.<br> Żeby dodać serwer do listy musi być online.", 1);
                }
             $ipcheck = mysql_num_rows(mysql_query("SELECT * FROM servers WHERE ip='".$ip."'"));
             if ($ipcheck > 0){
                $fel = 1;
                error("Ten adres Ip już jest zarejestrowany w bazie.", 1);
             }
             if ($fel != 1)
                {
                //Hämta xml info frĺn servern till variabeln $data
                $info = chr(6).chr(0).chr(255).chr(255).'info';
                $s = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
                socket_connect($s, $ip, $port);
                socket_send($s, $info, 8, 0);
                $a = '';
                $data = '';
                while(socket_recv($s, $a, 1024, 0))
                   {
                   $data .= $a;
                   }
                socket_close($s);
                
                //Ladda infon frĺn xml
                $stack = array();

                $xml_parser = xml_parser_create();
                xml_set_element_handler($xml_parser, "startTag", "endTag");
                xml_set_character_data_handler($xml_parser, "cdata");

                $data = xml_parse($xml_parser, $data);
                if(!$data) {
                   die(sprintf("XML error: %s at line %d",
                xml_error_string(xml_get_error_code($xml_parser)),
                xml_get_current_line_number($xml_parser)));
                }

                xml_parser_free($xml_parser);

                $info = array();
                foreachzor($stack, $info);
Go to the top of the page
+Quote Post
vokiel
post
Post #2





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Nie masz zdefiniowanej funkcji socket_create() co może być spowodowane Twoją wersją php:
Cytat
socket_create
(PHP 4 >= 4.0.7, PHP 5)


--------------------
Go to the top of the page
+Quote Post
yayco
post
Post #3





Grupa: Zarejestrowani
Postów: 32
Pomógł: 2
Dołączył: 22.01.2008

Ostrzeżenie: (0%)
-----


Sprawdziłem sobie i:

Current PHP version: 4.4.7
MySQL server version: 4.1.22-log

I co teraz? ;/
Go to the top of the page
+Quote Post
vokiel
post
Post #4





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Tak sobie dumam, że jeśli nie ma żadnej literówki, to jedynym wyjściem jest, że te funkcje nie są włączone.

Cytat
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.


Możesz sprawdzić czy w ogóle funkcja jest np tak:
  1. <?php
  2. if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
  3. echo "socket_create() nie zadziałał, powód: " . socket_strerror($sock) . "\n";
  4. }
  5. ?>


Ten post edytował vokiel 24.01.2008, 08:28:43


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 12:24