Jump to content

boen_robot

Members
  • Posts

    8,493
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by boen_robot

  1. It means looping until $entry is false. The value of $entry is changed right before each such check to become equal to whatever readdir() returns. It returns false on failure, and a failure occurs when there are no more folders left to be read. Nothing terribly fatal. I think files and folders can't be added and removed between opendir() and closedir() (well, they can... but the script trying to add/delete will wait until closedir()), but closedir() is automatically called at the end of the script if you don't call it yourself anyway.
  2. Yes... but you said And that is what thescientist is correction you about. Seeing that you caught your own error, I'm guessing this was just a typo, correct?
  3. boen_robot

    socket programing

    I just said that in my last post... So... go toStart > (All) Programs > Accessories > Command Promptand in the new window (that's the command line), type in"D:\Program Filess\xampp 1.7.4\php\php.exe" -f "D:\Program Filess\xampp 1.7.4\htdocs\socket\bb.php" and press Enter.
  4. There is also a "Cache" menu in IE's dev tools, from which you can temporarily (i.e. while you're testing) disable caching.
  5. boen_robot

    phone validation

    Consider sanitizing the phone number first. That way, you'll allow users to input it with dashes, spaces or other stuff that they'd use when writing out numbers.How do you do the sanitization? Easy: a single regular expression with preg_replace() that replaces every non-digit character with nothing. But first, you may want to change the leading "+" with "00", so: $phone = preg_replace(array('/^\+/', '/\D/'), array('00', ''), trim($_POST['phone'])); You can do any validation you need (minimal length, acceptable country codes, etc.) after that, which at that point would be much easier.
  6. boen_robot

    PHP and jQuery

    jQuery is a JavaScript library, not a PHP library.By the time JavaScript starts running, PHP is already finished, so there's no conflict. In fact, there's no way you could use JavaScript to get the source of the PHP file that generated the page. Not without the server's cooperation I mean.
  7. boen_robot

    socket programing

    You must run it from php.exe with the file as argument, like: "D:\Program Filess\xampp 1.7.4\php\php.exe" -f "D:\Program Filess\xampp 1.7.4\htdocs\socket\bb.php"
  8. boen_robot

    socket programing

    It looks as if you've swapped the client and server.Only the client echoes stuff, and it does so after it sends a message.The server should never echo anything, but should remain on until it is explicitly shut down.So try to run things the other way around: First, from the command line (this is VITAL!) run the file that currently gives the execution time error, and then run the file that currently produces the "??"s.
  9. boen_robot

    socket programing

    You are running the server from the command line, right? It shouldn't be started from a browser.You must enable php.exe in your firewall to run any server. Even better, you should add the port "6666" to explicitly allow this particular server. The point is that the firewall slows things down.(The IP is definitely not the problem though; that's the "localhost" IP, so there's nothing faster than that)
  10. boen_robot

    passwords as...

    When using PHPMyAdmin, I think it's a matter of a checkbox next to the column(s) you wish to be the primary key. So, if you decide to change the primary key, you need to first create the appropriate column that will become a primary key, and then change the checkbox accordingly.In terms of SQL syntax, I think it's something like "ALTER TABLE `users` ADD CONSTRAINT PRIMARY_KEY (`new_primary_key_column`)".
  11. boen_robot

    socket programing

    Did you actually downloaded the library? Where is it? Judging by the error message, the Autoload.php file (and the rest of the library files, mind you!) must be at either D:\Program Filess\xampp 1.7.4\php\PEAR\PEAR2\Net\Transmitter\Autoload.php or D:\Program Filess\xampp 1.7.4\htdocs\socket\PEAR2\Net\Transmitter\Autoload.php Where have you put the contents (the contents of the "src" folder that is) instead?
  12. boen_robot

    socket programing

    Remove any whitespace or any other code you may have before the "<?php"... do so in both files.Also, if you're using Notepad, save the file with ANSI encoding. If you're using another editor, save it as UTF-8 without BOM (Notepad can only save as UTF-8 with BOM).
  13. boen_robot

    Flash CS6?

    You could learn JavaScript (and/or jQuery) or you could learn Flash. Pick either one. It doesn't matter which one. In fact, try both, and see for yourself which is easier for you to deal with. There aren't many changes between CS3 and CS6, so if you know CS3, you pretty much know CS6 as well. But like I said, given the fact you're even asking whether Flash would work, I bet you don't really know any Flash.
  14. boen_robot

    socket programing

    How does a chat with one client look like? I mean, isn't a chat, by definition, a dialogue (i.e. between two parties)? Or do you want the server to respond with some predefined phrases?Assuming you want that... using my library, here's a very trivial server that first expects messages that are made up of 4 bytes, and responds with 2 byte messages. Connection is closed on a 'DONE' message, and server is terminated with a 'KILL' message: <?phpnamespace PEAR2\Net\Transmitter;require_once 'PEAR2/Net/Transmitter/Autoload.php';$server = stream_socket_server('tcp://127.0.0.1:6666');while (true) { try { $conn = new TcpServerConnection($server, -1); while ('DONE' !== $message = $conn->receive(4)) { switch ($message) { case '######': $conn->send('no'); break; case 'OPPS': $conn->send('oh'); break; case 'HERE': $conn->send('ty'); break; case 'KILL': break 3; default: $conn->send('??'); } } } catch (Exception $e) { echo $e; }} And here's a client that sends a few messages to that server, and echoes the responses: <?phpnamespace PEAR2\Net\Transmitter;require_once 'PEAR2/Net/Transmitter/Autoload.php';$c = new TcpClient('127.0.0.1', 6666);$c->send('######');echo $c->receive(2), "\n";$c->send('OPPS');echo $c->receive(2), "\n";$c->send('######');echo $c->receive(2), "\n";$c->send('DONE'); NOTE: To successfully run this, the server must be executed from the command line, and after that, the client must be executed either from another command line window or from a browser.
  15. boen_robot

    Flash CS6?

    Whether you use Flash or jQuery, a little programming know-how is required, so I have to ask... Why are you even chasing this to begin with? If that's what the client wants, then he needs a developer, not a designer. He would need a designer if he wants you to actually make one of the ads (his ad that is) that would be part of the rotation.If you still want to go on this route... *takes a deep breath in a sense of despair*JavaScript is available on most devices and browsers. jQuery is written in JavaScript, so the same applies to it as well. The difference is that with jQuery, you'll make people download the library in addition to your ad rotation code. jQuery should make it easier for you to do this than plain JavaScript, but we're talking about you, so it may not be easy for you. I mean, you've proven time and time again that things we say are "easy" don't apply to you (and we have yet to see the vice-versa).Flash is available on most desktop devices, though less so on mobile devices. If you don't really care about mobile devices, Flash is a good choice, and it should be easier, especially if you really know it from CS3 (which I doubt given the fact you're even asking the question).Note that when I talk about you caring about mobile devices, I really mean YOU. Don't bother asking the client. They will say that they want mobile devices, but if the rest of the site is not mobile friendly, the fact the ads will be is irrelevant, and you'll only burden yourself with work you can't possibly deliver with your current knowledge.
  16. boen_robot

    socket programing

    PHP isn't exactly suitable for creating socket servers (yet)...It doesn't have any threads or stuff like that, so it can't handle the multiple incoming connections that a chat would require.It does support forks using pcntl_fork(), but that extension is only available on UNIX systems. If you have some UNIX to test on (e.g. a host that happens to have the PCNTL extension available), you could do the server there.The way you work with TCP sockets is pretty much the way you work with files:1. If you're making a client, you specify a server to connect to, and at any time, you can either "read" (receive...) or "write" (send...) arbitrary data. The main difference with files is that the data you receive/read is independent from the data you send/write.2. If you're making a server, you specify an IP:port combo you want to receive client connections on, and then every time you're ready to handle a new incoming connection, you open a new stream where you (again) either "receive" (read) data from the client, or "send" ("write") data to it.The second thing is where PHP's problem is - you can't accept a new incoming connection while also dealing with another client. You have to, at some point, stop dealing with one client to deal with the next, and yet not forget to go back to the original client. When you don't have threads/forks, doing so is extremely inefficient.
  17. boen_robot

    socket programing

    The source for... my library? The link is in my signature, but if you insist, here:http://pear2.github.com/Net_Transmitter/The download link, as well as docs, are right at that page.
  18. boen_robot

    socket programing

    In the name of Mr. Herriman.Hi. Do you really need the socket functions? For plain ol' TCP and UDP sockets, you're better off using stream_socket_client() and stream_socket_server(). They are much more intuitive.You should also keep in mind that there are some things to watch out when you deal with sockets... namely the fact that sends and receives might be partial. You can see in my signature a small library I've made that abstracts those things away, so that you can just say "get me N bytes" and know for certain that you're getting N bytes.
  19. boen_robot

    passwords as...

    Not really... I mean, even if you use it as a foreign key in another table, there's an "ON UPDATE" action you can define on the foreign key. Yes, though data integrity is not it. Space and efficiency on INSERTs and UPDATEs are.
  20. Wait, what? How on Earth do you pull such a thing off? I mean, on the face of it (without being told anything more about this project), this doesn't sound much different from eBay, which hasn't really achieved such a thing, with the exception of one or two reputable providers per type of item sold... which isn't much different than having a Target or Wal-mart. It's just having it be online rather than offline. Sounds really cool . Do you have anything published yet? (needless to say I'd love to see what you mean by "interactive")With all this cool and (sort of) revolutionary stuff, my current projects sound boring, and are probably of interest only to few. I'm working on improving my library for communicating with MikroTik routers, and in addition to that, as a university... err... "diploma work" ("thesis"... I'm not sure of the term; It's a way to finish university with a bachelor's degree), a very minimal billing system that uses said library. A system which I'd also use at work.
  21. boen_robot

    Session

    You mean the session data? With the default "file" session handler, there is one file per session ID (which is in fact named after the session ID), and its contents is one that fits a custom format ("custom" as in "defined by the PHP developers") that PHP understands. I believe the contents is equivalent to writing the output of serialize($_SESSION) into a file, but I'm not sure honestly.You don't need to ever bother with it anyway, as you'll only ever be working with the $_SESSION superglobal array. If you develop your own session handler (e.g. one that writes to a DB, per your earlier suggestion), you can make the data look in any way you like, as long as you define a way to both read and write it.
  22. Judging by what Webstudio's "Try it" page says, you can't run Webstudio on a MAC. You'll have to look for a different program.
  23. boen_robot

    Ajax

    You're missing out really important pieces in the code you're presenting, but even from the little you're giving, it's clear that you're not setting the posTop and posLeft URL variables correctly.You have serverRequest.open("GET","updatePositions.php?player=1&posTop="+document.getElementById('player').style.posTop+"&posLeft="+document.getElementById('player').style.posTop,true); but there's no "posTop" property on the "style" object. The "style" object reflects the inline style (as you write them with the "style" attribute). From it, you have the "top" and "left" properties instead, i.e. serverRequest.open("GET","updatePositions.php?player=1&posTop="+document.getElementById('player').style.top+"&posLeft="+document.getElementById('player').style.left,true);
  24. You can get the extension, as well as the base name and directory name of a file with the pathinfo() function, which should significantly ease what you're trying to do.You could just do: $filename_parts = pathinfo($filename, PATHINFO_BASENAME | PATHINFO_EXTENSION);$filename_parts['basename'] = time() . '_' . $filename_parts['basename'];$filename = implode('.', $filename_parts);
  25. boen_robot

    Session

    Get your terminology straight, as your questions are starting to become confusing.The setcookie() function only contains these 7 arguments (sometimes called "parameters") that influence the cookie given to the browser by PHP.The value of any argument of any function may be a variable, a constant, a literal or the return value of a function.The session cookie is given to the browser at the start of a session, and is given back to the server, by the browser, at subsequent requests (like any other cookie). The value of the session cookie is a session ID. Upon calling session_start(), PHP reads the session ID in the session cookie, if such a cookie was sent. Every session ID is associated with session data. The session data is stored on the server. The client stores only the session cookie.By default, the session data lasts up to 1440 seconds or 24 minutes (according to what the PHP manual is saying about the current version; maybe this 15 minute thing was true once upon a time, I don't know), but this can be set to a different time in php.ini.By default, the session cookie lasts up until the user closes their browser, but this can be configured otherwise in php.ini or by calling the session_set_cookie_params() function with appropriate values for its arguments.There is a lot going on with sessions, so you need to know your terms before you can grasp not only the "what", but also the "why". If you don't understand my explanation above, please point to a specific term (any of the bold stuff) so that we can clarify that further.
×
×
  • Create New...