Jump to content

510carlos

New Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

510carlos's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I need help I have spent countless hours attempting to learn and I am about to pull my hair. My task that I want to accomplish is: Send a packet to the server and make the server ping back the client. I want to calculate the time it takes to complete the connection. I have been trying to send a packet form the client to the server. Receive it from the server and send it back to the client. I have code that I have been trying but it doesn't not work. Server: <?php //Create the socket on the specified port. $socket = socket_create_listen($port); //Wait for incoming connections. $connection = socket_accept($socket); //Create a socket and connect it to the server. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_connect($socket, 'localhost', 33335); //Create a message, and send it to the server on $socket. $message = "This is a message from the client.\n"; socket_send($socket, $message, strlen($message), MSG_EOF); //Close the socket. socket_close($socket); ?> Client: <?php //Create a socket and connect it to the server. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_connect($socket, 'localhost', 33335); //Create a message, and send it to the server on $socket. $message = "This is a message from the client.\n"; socket_send($socket, $message, strlen($message), MSG_EOF); //Close the socket. socket_close($socket); ?>
  2. I am just trying out PDO and I get this error, Fatal error: Call to a member function fetch() on a non-object, but isn't it already on the $this->db object? class shoutbox { private $db; function __construct($dbname, $username, $password, $host = "localhost" ) { # db conections try { $this->db = new PDO("mysql:host=".$hostname.";dbname=".$dbname, $username, $password); } catch(PDOException $e) { echo $e->getMessage(); } } function getShouts() { $sql_shouts = $this->db->query('SELECT shoutid, message, pmuserid, ipadress, time FROM shouts WHERE pmuserid == 0'); return $sql_shouts->fetch(PDO::FETCH_OBJ); } }
×
×
  • 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.