Jump to content

bozebo

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

About bozebo

  • Birthday 12/02/1990

Contact Methods

  • MSN
    webmaster@bozebo.com
  • Website URL
    http://www.bozebo.com

Profile Information

  • Gender
    Male
  • Location
    Scotland

bozebo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. well, seeing as you hate timestamps theres not much you can do that allows easy manipulation, andyb's suggestion is very good though. yyyy-mm-dd is the international standard for dates and it is good for verification and manipulation. using some good regular expressions and the php function: strtotime() along with date("Y-m-d") will allow you to achieve this
  2. ultimately, php i capable of making any file type if the relevant addons and libraries are in place, you may have heard of the gd library for images (http://uk3.php.net/gd). as for zips, there are bult in functions described well here: http://www.w3schools.com/php/php_ref_zip.asp. I myself havn't done much of this but its usually easy enough to find examples and tutorials by googling. try: 'PHP Pdf creation'
  3. you might need the ports opened/forwarded correctly so that it can connect via the internet, though I am unsure.
  4. seems to me like the mysql service isnt started, php cant help it if thats the case But i am not sure, there is nothing wrong with your code thats for sure edit: or there could be any number of less likely possibilities
  5. Sorry I can't figure out what you are trying to say, can we see the part that you seem to have left out? the most important part.. where you said: "(i have the sql query part of the code here)" Also, use the [ php][/php ] bbcode instead of [ code][/code ] so it's nicely highlighted (remember to have <?php and ?> in it or it wont be highlighted - also, I had to put spaces to break the bbcode I entered above ^) I will track this topic and return to help you soon
  6. Hi, I have been playing around with PHP desktop applications and I am curious of it's potential. I am attmpting to transfer a small file (probably no more than 15 kB) through sockets from a client to a server, both programmed in PHP. I think my bug lies somewhere in the client's handling of the file before it sends it off to the server but I am unsure. I will post the code now and discuss it below: <?php /* SERVER */ $address = "127.0.0.1"; $port = "10000"; $mysock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); socket_bind($mysock,$address,$port); socket_listen($mysock,5); echo "Waiting for a client...\n"; $client = socket_accept($mysock); echo "Server started\n"; $file = ''; // <-- this is 2 apostrophies by the way sleep(2); $input = socket_read($client,2048); while(!feof($input)){ $file .= $input; $input = socket_read($client,2048); } file_put_contents('destination.bmp',$file); socket_close($client); socket_close($mysock); echo "Server ending...\n"; ?> <?php /* CLIENT */ $address = "127.0.0.1"; $port = 10000; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } else { echo "socket successfully created.\n"; } echo "Attempting to connect to '$address' on port '$port'..."; $result = socket_connect($socket, $address, $port); if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { echo "successfully connected to $address.\n"; } $file = file_get_contents('source.bmp'); socket_write($socket,$file); echo "Closing socket..."; socket_close($socket); ?> I have written some multi-client socket servers before and even run a small (and buggy) orpg, but never sent a file. To simplify things I took code from a basic talkback server I found on php.net and made my alterations. Basically, I run the server and then the client afterwards, it seems to connect fine, but when the client sends the file I get an error in the server window: "feof() supplied argument is not a valid stream resource" so, is this error due to how the client sends the file? or how the server attemts to receive it.. or possibly both. I have no idea. Also: I have spent a while googling for some tutorial or example of this in PHP but couldn't find any (kept getting file upload ones ). Probably because there is no particular reason to do this in PHP... Thanks in advance for any help I get.
  7. The primary difference is what they return, ereg "Returns the length of the matched string if a match for pattern was found in string , or FALSE if no matches were found or an error occurred." whereas preg_match "returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match" preg_match also has some other arguments for more complicated uses
  8. OK, here is my regular expression for you to try: [a-z0-9,';_-]* I tested it at http://regexlib.com/RETester.aspx and it seems fine, Now I will go over it for you: the [ and ] show that everything in them matches one character (as the * means 0 or more of the last match) so, the characters you want to match are in there: a-z is a range of any lower case letter (but you are using eregi to ignore case). 0-9 is a range of any numeric characters. the comma is just a comma, likewise with the apstrophy and underscore. But the dash is the interesting one, it must go at the end otherwise it will look for a range of characters, escaping it didn't seem to work.
  9. Sorry to be lazy at the moment, but maby If I give you a refined version of my own pagignation you can sort yours out: $cards_per_page = 10; if ($_GET['page'] > 0){ $page_number = $_GET['page']; } else { $page_number = 1; } $cardsq = 'SELECT * FROM tblCards'; $cards_data = mysql_query($cardsq) or die(mysql_error()); $pages = ceil(mysql_num_rows($cards_data) / $cards_per_page); if ($page_number > $pages){ $page_number = $pages; } $p_start = ($page_number * $cards_per_page) - $cards_per_page; $cardsq = 'SELECT * FROM tblCards LIMIT '. $p_start .', '. $cards_per_page; $cards_data = mysql_query($cardsq) or die(mysql_error() .' Query:<br />'. $cardsq ); if ($pages > 1){ echo '<p>Page:<br />'; for($i = 1; $i <= $pages; $i++){ if ($page_number != $i){ echo ' <a href="?action=lookup_card&page='. (string)$i .'">'. (string)$i .'</a>'; } else { echo ' '. (string)$i; } echo '</p>'; } } while($card = mysql_fetch_assoc($cards_data)){ //do something for each record that is on this page } if ($pages > 1){ echo '<p>Page:<br />'; for($i = 1; $i <= $pages; $i++){ if ($page_number != $i){ echo ' <a href="?action=lookup_card&page='. (string)$i .'">'. (string)$i .'</a>'; } else { echo ' '. (string)$i; } } echo '</p>'; };
  10. you need to loop through all recipients and send individual emails each time (your webhost may not like this) as an example: $recipients = array('email@email.com','email@email.com','email@email.com','email@email.com'); $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); foreach($recipients as $to){ mail($to, $subject, $message, $headers); }
  11. Well.. we can start off by highlighting it: $id = $_GET['id']; if ($id = 1){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' ORDER BY game_id DESC LIMIT 18"); echo "<center><h2>Most Recent 18</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 2){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Action' ORDER BY game_id DESC"); echo "<center><h2>Action Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 3){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Sports' ORDER BY game_id DESC"); echo "<center><h2>Sports Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } else if ($id = 4){ $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Puzzle' ORDER BY game_id DESC"); echo "<center><h2>Puzzle Games</h2></center> <center> (Select Category at Side Bar) </center> <br />"; while($row = mysql_fetch_array($result)) { echo " <div id='gamelisting'> <center> <a href='game.php?id=" . $row['game_id'] . "'> <img src='" . $row['game_icon'] . "' width='75' height='75' alt='" . $row['game_name'] . "' /> </a> <br />" . $row['game_name'] . " </center> </div>"; } } Ok I have cut out the latter repetitions of that big if statement because It is likely that your problem is repeated. I think there is a problem in your mysql query because the php seems correct. Try swapping the queries for this: $result = mysql_query("SELECT * FROM warp_games WHERE game_verified='yes' AND game_category='Sports' ORDER BY game_id DESC") or die(mysql_error()); That way it will tell you what is wrong with the query.
  12. I have never been able to get ajax to work, I have followed about 50 tutorials and nothing ever happens, I need some help. I have vastly simplified what I am trying to do into a test, Ill I want it to do is alert if the page it reads has "1" in it... Shouldn't that be simple? My most recent attempt is modeled closely on the tutorial on ajaxfreaks.com ("Simple Introduction to AJAX and XMLHttpRequest") function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('Problem creating the XMLHttpRequest object'); } return req; } // Make the XMLHttpRequest object var http = createRequestObject(); function sendRequest(act) { // Open PHP script for requests http.open('get', 'other/is_in_game.php?gameid='+act); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.status == 200){ if(http.readyState == 4){ // Text returned FROM the PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content alert('IT WORKED!!!'); } } } else { alert('Something went wrong'); } } The page it reads (http://www.bozebo.com/knightlands/other/is_in_game.php) contains simple php to set the headers correctly, and it prints "1" on the page.. so the whole file through http is jus "1".. So my ajax script should work every time without fail?? It doesn't. You can find my test here: http://www.bozebo.com/knightlands/ajaxtest.html Can anyone help me? Or am I just cursed...
  13. ehm.. what? thanks for giving me a useless reply, now nobody will help because it has replies... Was just reading this and thought having never used shuffle() before that I couldn't see why it doesn't work. So I followed darkfreaks link, and the answer is there for you. Although I did have to scroll down the page to the user notes to find it. Hint: oh? ill take a look edit: OH.. I was dumb to not notice that lol. Thanks.. (but darkfreaks' reply wasnt actually any help caus he thought the same thing as me ) OH lol.. now i have [sOLVED][not solved!].. ah well
  14. ehm.. what? thanks for giving me a useless reply, now nobody will help because it has replies...
×
×
  • 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.