Jump to content

konnwat

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.costscastle.com

Profile Information

  • Gender
    Male
  • Location
    UK

konnwat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well i have 2 tables. table1 has `datetime` `name` `language` `points` `group` `rank` table2 has `position` `name` `rank` `points` `group` I need to copy the first one over to the second one and the position is based on the points. I thought the best way was to use... INSERT INTO table2 (position, name, rank, points, group) SELECT (0, name, rank, points, group) ORDER BY DESC But table1 has some duplicates of `name`. I need to be able to copy the table with no duplicates so i thought about making the column Unique but i dont know how i would go about doing that for a text column. Also I thought the position could be done by Auto Increasement but then everytime the table updates i need to set the default position back to 1 and i dont know how to do that either. (I thought if i set the default to 1 and Truncate the table it might work but i havent tried) Can anyone help me? Thanks
  2. hehe i was going to say through a session but i was beaten too it xD <?php session_start(); $_SESSION['key'] = 'value'; //in the other php file you can put session_start(); $var = $_SESSION['key']; ?>
  3. Hey i made a nice bot that opens a socket, gets some html, parses it and adds the information to a db. but... the site now needs you to be logged in to view the source! so how would i go about making it log in? :-\ i was thinking sending some headers to the socket that has the session cookie in them but i dont know how i would do that :-X here is my code... <?php $fp = fsockopen("www.barafranca.com", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /compress.php?r=stats.inc HTTP/1.1\r\n"; $out .= "Host: barafranca.com\r\n"; $out .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204\r\n"; $out .= "Connection: Close\r\n\r\n"; $file = ''; fwrite($fp, $out); while (!feof($fp)) { $file .= fgets($fp, 128); } fclose($fp); } ?>
  4. <?php $var = 1*$var; ?> quite simple just do some maths with a string and if its a number it will turn into a float/int
  5. Please someone
  6. Im confused. I've got a 10 png images, with aplha, of the numbers 0-9 they all have the same hight but not the same width. I got a mysql database with a counter number and i made a counter works fine, but its not in aplha :s heres my code... <?php //str_split if(!function_exists('str_split')){ function str_split($string,$split_length=1){ $count = strlen($string); if($split_length < 1){ return false; } elseif($split_length > $count){ return array($string); } else { $num = (int)ceil($count/$split_length); $ret = array(); for($i=0;$i<$num;$i++){ $ret[] = substr($string,$i*$split_length,$split_length); } return $ret; } } } //connect to mysql $mysqlLink = mysql_connect(----------------); mysql_select_db(--------------); //get id if(isset($_GET['id'])) { $id = $_GET['id']; } else { $id = '1'; } //get count number and +1 $result = mysql_query("SELECT * FROM counters WHERE ID=".$id); $rows = mysql_fetch_array($result); $count = $rows['Count']; if ($_COOKIE[$id] != 'done') { $count++; mysql_query("UPDATE counters SET Count = '$count' WHERE ID=".$id); //set cookie setcookie($id, 'done', time()+60); } //split the count $numbers = str_split($count); $digits = count($numbers); $nextwidth = 0; //make image header ("Content-type: image/png"); for($i=0; $i<$digits; $i++) { list($width, $height, $type, $attr) = getimagesize("numbers/{$rows['Type']}/{$numbers[$i]}.png"); $nextwidth += $width; } $im = imagecreate($nextwidth, $height); imagesavealpha($im, true); $nextwidth = 0; imagecolorallocate($im, 0, 0, 0); for($i=0; $i<$digits; $i++) { list($width, $height, $type, $attr) = getimagesize("numbers/{$rows['Type']}/{$numbers[$i]}.png"); $image[$i] = imagecreatefrompng("numbers/{$rows['Type']}/{$numbers[$i]}.png"); imagesavealpha($image[$i], true); imagecopymerge($im,$image[$i], $nextwidth, 0, 0, 0, $width, $height, 100); $nextwidth += $width; } imagesavealpha($im, true); imagepng($im); ?> i have imagesavealpha($im, true); in 3 times, i tried it everywhere :s please help thanks
  7. why don't you try making one :P when you log on to program, write to a txt file or a MySQL database that your on and then [code]<?php $online = file_get_contents(''data.txt"); if($online = "yes") {     echo "Live chat!"; } ?>[/code] and use a java IRC client for help :P well its free ^^
  8. [code]<?php try { eval('will cause error'); } catch (Exception $e) {   echo 'Caught exception: '.$e->getMessage()."\n"; } ?>[/code] try that ^^
  9. okay i got it,it seems for no reason my bot runs the whole script again and again every now and then :P this is my connect code. [code] <?php set_time_limit(0); //set vars $host = 'irc.barafranca.com'; $port = '6667'; $nickname = "Bot"; $channel = file('../bot/channels.txt'); //open data.txt and botlines.txt $cokehandle = fopen('../coke/data.txt', w); $lineshandle = fopen('../botlines.txt', a); fwrite($lineshandle, "\n\n\n"); $killmode['#chan'] = 'on'; $ks = array(); //connect to IRC $socket = fsockopen($host, $port); stream_set_timeout($socket, 60*60*24*365); fwrite($socket, "NICK ".$nickname."\r\n"); fwrite($socket, "USER ".$nickname." 8 * :Nick's Bot\r\n"); fwrite($socket, "MODE ".$nickname." +B\r\n"); while ($line=fgets($socket)) {   if (strpos($line, "433")>0) die();   if (strpos($line, "004")>0) {       $chancount = count($channel);       fwrite($socket, "PRIVMSG nickserv :IDENTIFY Bot hello123\r\n");       for ($i = 0; $i < $chancount; $i++) {             fwrite($socket, "JOIN ".$channel[$i]."\r\n");       }       break;   } } ?>[/code] there is a [color=blue]$lineshandle[/color]  to log my lines and there are a lot of random "\n\n\n" in the middle of all the lines. this must mean that my whole php script just randomly starts again after a while :s and some times is give me an EOF because it doent run again, it just ends :P how do i stop this?
  10. yeah i started posting that post and then the forum said someone else had posted but i didn't go back and read what you said so i just posted. sorry bout that ;)
  11. its the servertime and it must have been retrieved with the time() function try [URL=http://uk.php.net/time]http://uk.php.net/time[/URL]
  12. change file() to file_get_contents() that returns it all in one string instead on an array per line.
  13. [quote author=SharkBait link=topic=123057.msg508762#msg508762 date=1169235895] Are you able to output or log the incomming server text? Perhaps it will tell you why you're the bot is timing out? I haven't used php sockets but I have done my own IRC Client with VB.NEt and I can toggle on/off the parsing of the IRC server text.  Sometimes it can give you clues as to why you connection drops/timesout. [/quote] yes i can, i said this in a previous post. there seems to be no common link of why my bot is leaving.
  14. NICE, thats gotta work, thanks ^^
  15. [url=http://info-x.co.uk/fp_8706.asp]http://info-x.co.uk/fp_8706.asp[/url] says that it works :O
×
×
  • 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.