Skip to main content

Posts

Is it possible to serialize a WebSocket connection object and reuse it on another server?

I wanted to setup load balancing for my website and so when you request to the websocket address it will then route your connection to a WebSocket server with the most resources available at the current request time. My website is a chat website and updating the chat for other users with WebSockets isn't very hard if it's all running on one server. Let's say User one sends a message to TestUser. User has a connection ID of 120 and TestUser has the ID of 174, Now the server will look through the connections that match the user and get the ID then get the connection and then send the response to TestUser. But if both users are on two different servers and I store their connections on a database in a serialized form and then get them to a variable, Can I still use that connection? Do the connections contain some kind of authentication to send a message as a server? If not what could I try. I do not want to replace my load balancer with a single server. Thanks! NOTE: I li

Data push via Ajax/Post

I built an PHP/Ajax script to send mass newsletter emails through PHPMailer which works perfectly fine except getting the value from HTML INPUT BOX for the subject of the email. The table gets the value from MySQL database with the following HTML/Bootstrap; <div class="table-responsive"> <table class="table table-bordered table-striped"> <tr> <th>Customer Name</th> <th>Email</th> <th>Select</th> <th>Action</th> </tr> <?php $count = 0; foreach($result as $row) { $count = $count + 1; echo ' <tr> <td>'.$row["customer_name"].'</td> <t

String comparison in PHP doesn't make sense … [duplicate]

I have this really basic PHP code I can't figure out. In the example below, why do I get 'MATCH' when $i = 0, and not for the remaining rows …? It seems to be possible to workaround by using === instead of ==, but I can't understand why. <?php $text = 'foo bar'; for ($i = 0; $i <= 5; $i++) { echo '<p>' . $i . ': '; if ($i == $text) { echo 'MATCH!'; } else { echo 'NOPE'; } } ?> source https://stackoverflow.com/questions/67731189/string-comparison-in-php-doesnt-make-sense

My aws instance get down when someone refresh too much [closed]

This is just crazy, for some reason I can't figure out, my instance get down when someone hit refresh too much and I have to restart it, so anyone has the power to get it down, The instance has an apache2 server I've been watching the logs but I don't find anything weird, do you have any clue? source https://stackoverflow.com/questions/67725199/my-aws-instance-get-down-when-someone-refresh-too-much

Trying to use a native port of the Trader extension in PHP

I'm trying to use the LupeCode\phpTraderNative at https://github.com/LupeCode/phpTraderNative I'm an "old school BASIC GOTO 10 procedural coding" kinda guy, though I've often used other libraries that use namespaces, objects, classes, and whatnot but there's usually an example included on how to use them. This one hasn't. The documentation states: If you had trader_adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod) You can swap that with Trader::adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod) You only need to change trader_ to Trader::. That's it! So after installing it with composer and requiring the vendor/autoload.php i'm having a hard time figuring out how to use Trader:: in my code. Fatal error: Uncaught Error: Class "Trader" not found in I tried several things like: use Lupecode\phpTraderNative; or $var = new Trader(); And variations, even tried including files from the source. But nothing se

Create multiple rows in Laravel DB with a single form

i have a form trying store multiple rows in my DataBase with laravel and JQuery .append. But when i submits it only stores the last one. I will like to store all the appends separately. I don’t know how to fix this. I hope you can help me a little bit. I will really appreciate your help. Here's my code. Blade <form action="" method="POST" enctype="multipart/form-data"> @csrf <div class="container-fluid p-0"> <h1 class="h3 mb-3">Crear Cotización</h1> <br /> <br /> <div class="row"> <div class="col-sm-3"> <div class="form-group"> <label>Usuario</label> <select name="id_usuario" id="id_usuario" class="form-control"> <option va